Skip to content

Conversation

tatsuhiro-t
Copy link
Member

This commit introduces time to count certain events in specific duration of time.

nghttp3_tstamp is the time instant, and nghttp3_duration is the duration of time. Both are nanosecond resolution. Some macros such as NGHTTP3_SECONDS have been introduced for convenience.

nghttp3_settings has been extended, and an application should set the initial timestamp to initial_ts field.

nghttp3_conn_read_stream has been deprecated in favor of nghttp3_conn_read_stream2 which takes nghttp3_tstamp as a final parameter.

@tatsuhiro-t tatsuhiro-t added this to the v1.12.0 milestone Sep 11, 2025
Copy link

@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.

Summary of Changes

Hello @tatsuhiro-t, 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 integrates a robust timekeeping mechanism into the library, enabling the tracking of events with nanosecond precision. It introduces new data types for timestamps and durations, along with utility macros for common time units. The nghttp3_settings structure has been enhanced to allow for an initial timestamp, and a new stream reading function, nghttp3_conn_read_stream2, has been added to leverage this new timing capability, replacing its predecessor.

Highlights

  • New Time Types and Macros: Introduced nghttp3_tstamp and nghttp3_duration types for nanosecond resolution time, along with convenience macros like NGHTTP3_NANOSECONDS, NGHTTP3_MICROSECONDS, NGHTTP3_MILLISECONDS, and NGHTTP3_SECONDS.
  • Extended nghttp3_settings: The nghttp3_settings structure has been extended with a new initial_ts field, allowing applications to provide an initial timestamp to the library.
  • Deprecated nghttp3_conn_read_stream: The function nghttp3_conn_read_stream has been deprecated in favor of nghttp3_conn_read_stream2, which now accepts an nghttp3_tstamp parameter for more precise timing of stream data processing.
  • Settings Version Update: The internal settings version has been updated to NGHTTP3_SETTINGS_V3 to reflect the new additions and changes.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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

@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 introduces time-related data types and functionality to the library, including nanosecond-resolution timestamps and durations. The changes are well-implemented across the API, documentation, and tests. A new function nghttp3_conn_read_stream2 is added to accept a timestamp, and the old function is deprecated. My review found one potential issue in the new timestamp handling logic that could lead to state corruption, for which I've provided a suggestion.

@tatsuhiro-t tatsuhiro-t force-pushed the tstamp branch 2 times, most recently from bb7203f to 9c70476 Compare September 11, 2025 10:39
@tatsuhiro-t
Copy link
Member Author

/gemini review

Copy link

@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 introduces time-related data types and functions to enable tracking of events over time. The changes include new typedefs for timestamp and duration, an initial_ts field in nghttp3_settings, and a new nghttp3_conn_read_stream2 function that accepts a timestamp. The existing nghttp3_conn_read_stream is deprecated. The implementation is consistent across the library, documentation, and tests. I have one suggestion to improve the robustness of the versioned settings struct size calculation.

Comment on lines +91 to +94
return offsetof(nghttp3_settings, origin_list) +
sizeof(settings.origin_list);

Choose a reason for hiding this comment

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

medium

Using offsetof with the first field of the next version is a more robust way to determine the size of a versioned struct, as it correctly handles potential compiler padding between members. The current approach of offsetof(last_field) + sizeof(last_field) can be incorrect if there's padding after last_field.

    return offsetof(nghttp3_settings, initial_ts);

This commit introduces time to count certain events in specific
duration of time.

nghttp3_tstamp is the time instant, and nghttp3_duration is the
duration of time.  Both are nanosecond resolution.  Some macros such
as NGHTTP3_SECONDS have been introduced for convenience.

nghttp3_settings has been extended, and an application should set the
initial timestamp to initial_ts field.

nghttp3_conn_read_stream has been deprecated in favor of
nghttp3_conn_read_stream2 which takes nghttp3_tstamp as a final
parameter.
@tatsuhiro-t tatsuhiro-t merged commit e757c71 into main Sep 11, 2025
36 checks passed
@tatsuhiro-t tatsuhiro-t deleted the tstamp branch September 11, 2025 12:29
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