Skip to content

add: refcount in tracing (#269)#270

Merged
VasilyStepanov merged 1 commit intoreleases/v0.1from
v0.1/tracing
Mar 8, 2026
Merged

add: refcount in tracing (#269)#270
VasilyStepanov merged 1 commit intoreleases/v0.1from
v0.1/tracing

Conversation

@VasilyStepanov
Copy link
Copy Markdown
Member

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)

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)
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 TraceEvent objects, ensuring proper resource management. It also modernizes trace message generation by transitioning from std::ostringstream to a more efficient printf-style variadic argument approach, streamlining diagnostic information capture and logging 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.
Changelog
  • librawstorio/src/poll_event.cpp
    • Updated trace messages to use printf-style formatting.
  • librawstorio/src/poll_event.hpp
    • Modified trace event message calls to align with the new printf-style format.
  • librawstorio/src/task.cpp
    • Converted trace event initialization and messages to use printf-style formatting.
  • librawstorio/src/uring_buffer.cpp
    • Updated trace messages to use printf-style formatting.
  • librawstorstd/include/rawstorstd/logging.h
    • Introduced new C-style functions for TraceEvent reference counting (rawstor_trace_event_inc, rawstor_trace_event_dec) and va_list based message formatting (rawstor_trace_event_va_begin, rawstor_trace_event_va_message).
  • librawstorstd/include/rawstorstd/logging.hpp
    • Refactored the TraceEvent class and its associated macros (RAWSTOR_TRACE_EVENT, RAWSTOR_TRACE_EVENT_MESSAGE) to support printf-style variadic arguments and implement reference counting logic, including a copy constructor and updated destructor.
  • librawstorstd/src/logging.cpp
    • Implemented the core logic for TraceEvent reference counting within the Event class and provided definitions for the new C-style va_list based tracing functions.
  • src/ost_session.cpp
    • Updated trace messages to use printf-style formatting.
  • src/task.hpp
    • Converted trace event initialization to use printf-style formatting.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread librawstorstd/include/rawstorstd/logging.hpp
@VasilyStepanov VasilyStepanov merged commit 0ffd222 into releases/v0.1 Mar 8, 2026
19 checks passed
@VasilyStepanov VasilyStepanov deleted the v0.1/tracing branch March 8, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant