Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Optimize span and trace ID generation #1521

Merged
merged 2 commits into from
Sep 13, 2023
Merged

Conversation

fbogsany
Copy link
Contributor

@fbogsany fbogsany commented Sep 13, 2023

This improves the performance of span and trace ID generation by avoiding the loop overhead in the common case of rand returning a valid ID.

Benchmark results:

Comparison:
generate_trace_id_while:  8023027.6 i/s
   generate_trace_id:  4328017.1 i/s - 1.85x slower
...
Comparison:
generate_span_id_while:  8364182.8 i/s
    generate_span_id:  4382207.1 i/s - 1.91x slower

@fbogsany fbogsany merged commit cf8a18b into main Sep 13, 2023
48 checks passed
@robertlaurin robertlaurin deleted the optimize-id-generation branch September 13, 2023 21:34
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.

3 participants