add: refcount in tracing (#269)#270
Conversation
This pull request significantly refactors the tracing infrastructure by implementing a robust reference counting mechanism for `TraceEvent` objects, ensuring proper resource management. Concurrently, it modernizes the trace message generation by transitioning from `std::ostringstream` to a more efficient and flexible `printf`-style variadic argument approach, streamlining how diagnostic information is captured and logged throughout the system. ### Highlights * **Reference Counting for Trace Events**: Introduced a reference counting mechanism for `TraceEvent` objects to manage their lifecycle and prevent resource leaks. * **Printf-style Tracing**: Migrated the tracing macros (`RAWSTOR_TRACE_EVENT`, `RAWSTOR_TRACE_EVENT_MESSAGE`) to use `printf`-style variadic arguments, replacing `std::ostringstream` for message formatting. * **Expanded Logging API**: Added new C-style functions (`rawstor_trace_event_va_begin`, `rawstor_trace_event_inc`, `rawstor_trace_event_dec`, `rawstor_trace_event_va_message`) to the logging API to support the new reference counting and variadic argument approach. * **Codebase-wide Trace Update**: Updated existing trace message calls across various files in `librawstorio` and `src` to conform to the new `printf`-style formatting. (cherry picked from commit 4953d92)
Summary of ChangesHello @VasilyStepanov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the tracing infrastructure by introducing a robust reference counting mechanism for Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a solid improvement, refactoring the tracing infrastructure to use reference counting for TraceEvent objects and switching to more efficient printf-style logging. The implementation is clean and the changes are applied consistently across the codebase. I've found one potential high-severity issue in the TraceEvent copy constructor that could lead to a crash under certain conditions. Once that is addressed, this PR will be in great shape.
This pull request significantly refactors the tracing infrastructure by implementing a robust reference counting mechanism for
TraceEventobjects, ensuring proper resource management. Concurrently, it modernizes the trace message generation by transitioning fromstd::ostringstreamto a more efficient and flexibleprintf-style variadic argument approach, streamlining how diagnostic information is captured and logged throughout the system.Highlights
TraceEventobjects to manage their lifecycle and prevent resource leaks.RAWSTOR_TRACE_EVENT,RAWSTOR_TRACE_EVENT_MESSAGE) to useprintf-style variadic arguments, replacingstd::ostringstreamfor message formatting.rawstor_trace_event_va_begin,rawstor_trace_event_inc,rawstor_trace_event_dec,rawstor_trace_event_va_message) to the logging API to support the new reference counting and variadic argument approach.librawstorioandsrcto conform to the newprintf-style formatting.(cherry picked from commit 4953d92)