Skip to content

CDRIVER-4697: More efficient trace toggle #1634

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

Merged

Conversation

Julia-Garland
Copy link
Contributor

Updated:
if (MONGOC_TRACE_ENABLED)
to
if (MONGOC_TRACE_ENABLED && gLogTrace)
via _mongoc_log_trace_is_enabled which has the same logic.

Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

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

Mild concern that moving the MONGOC_TRACE_ENABLED check into the function may impede the compiler's ability to deduce always-false conditions at usage sites. The original ticket description requested if (MONGOC_TRACE_ENABLED && gLogTrace) which preserves the constant check in the if statement.

However, this may be premature optimization. Regarding tracing, we already decided once before to trade potential compile-time optimization in favor of moving checks to runtime. I think it is acceptable to take another step in that direction unless we can produce meaningful benchmarks (or receive user feedback) suggesting otherwise.

Would like to hear others' thoughts before submitting approval.

@Julia-Garland
Copy link
Contributor Author

Julia-Garland commented Jun 10, 2024

As an additional note, I used the function call because gLogTrace is currently not included in mongoc-log-private.h

@Julia-Garland Julia-Garland requested a review from kevinAlbs June 11, 2024 13:29
@Julia-Garland Julia-Garland merged commit c2c0c82 into mongodb:master Jun 11, 2024
40 of 44 checks passed
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