-
Notifications
You must be signed in to change notification settings - Fork 130
perf: Optimize telemetry latency logging to reduce overhead #715
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
Conversation
Optimizations implemented: 1. Eliminated extractor pattern - replaced wrapper classes with direct attribute access functions, removing object creation overhead 2. Switched from time.perf_counter() to time.monotonic() for faster timing 3. Added feature flag early exit - checks cached telemetry_enabled flag to skip heavy work when telemetry is disabled 4. Simplified code structure with early returns for better readability Performance impact: - When telemetry disabled: ~95% overhead reduction (only timing + debug log) - When telemetry enabled: ~50-70% overhead reduction - Overall: Reduces telemetry overhead from ~10% to 0.5-3% The decorator now: - Always logs latency at DEBUG level for debugging - Exits early using cached connection.telemetry_enabled flag (avoids dict lookup) - Only performs data extraction and object creation when telemetry is enabled
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
Optimizations implemented:
1. Latency Logger (latency_logger.py):
- Eliminated extractor pattern - replaced wrapper classes with direct
attribute access functions, removing object creation overhead
- Switched from time.perf_counter() to time.monotonic() for faster timing
- Added feature flag early exit - checks cached telemetry_enabled flag
to skip heavy work when telemetry is disabled
- Simplified code structure with early returns for better readability
2. Feature Flag Caching (feature_flag.py):
- Changed cache key from session_id to host
- Feature flags now shared across multiple connections to same host
- Reduces network calls - first connection fetches, subsequent reuse cache
Performance impact:
- When telemetry disabled: significantly reduced overhead (only timing + debug log)
- When telemetry enabled: reduced overhead from data extraction optimizations
- Feature flag: Only fetched once per host instead of per session
- Overall: Reduces telemetry overhead substantially
The decorator now:
- Always logs latency at DEBUG level for debugging
- Exits early using cached connection.telemetry_enabled flag
- Only performs data extraction and object creation when telemetry is enabled
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
When force_enable_telemetry=True, skip the feature flag network call entirely since we already know telemetry should be enabled. This optimization: - Eliminates unnecessary network call during connection init - Faster connection setup when telemetry is forced on - Clearer control flow with early returns
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
Split long lines to comply with Black's 88 character limit
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
Changed _events_batch to _events_queue.qsize() to match the lock-free queue implementation
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
The decorator was using 'return' statements in the finally block, which suppressed exceptions raised in decorated methods. This caused downloader tests to fail as exceptions (ConnectionError, TimeoutError) were being swallowed. Fixed by nesting telemetry logic inside an if statement instead of using early returns, ensuring exceptions propagate correctly.
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
nikhilsuri-db
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am mostly aligned with your PR too, just not able to pin how these changes improved the benchmarking numbers. It will be great if we can measure the changes with the improvements they bring to the benchmarking numbers.
Most of the improvements I see in benchmarking in my opinion is coming from extractor pattern removal (this cuts object creation and method call) |
Resolved merge conflict in telemetry_client.py by keeping Queue optimization while incorporating new telemetry push client with circuit breaker support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
Summary
Changes
telemetry_enabledflag to skip heavy work when telemetry is disabledPerformance Impact
Internal doc : https://docs.google.com/document/d/1sV_N3IXhzH5aAoAOOhc4sA49ZdINGii_wXvYNyZdVEo/edit?tab=t.0#heading=h.ezkw4po8o1mx
~ 8% improvement across test cases.
Behavior Changes
connection.telemetry_enabledflag (avoids dictionary lookup + instance check on every operation)Test Plan