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

perf: Optimize has_more_than_n_keys function and BatchTraceProcessor #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tongshu1943
Copy link

Feature Description

Implemented performance optimizations in two key areas of the codebase:

  1. Replaced inefficient key counting method in has_more_than_n_keys function with a more efficient approach
  2. Optimized the BatchTraceProcessor class to improve trace and span export performance

Specific Improvements

  1. Modified has_more_than_n_keys function to use len(obj) directly instead of iterating through keys
  2. Optimized _export_batches method to reduce queue checks and improve batching logic
  3. Added tests to verify the optimized functions work correctly

Technical Implementation

  • Dictionary key counting: Using len(obj) directly is more efficient than iterating through all keys
  • Trace batch processing: Reduced the number of queue checks and improved the batching logic
  • Both optimizations maintain existing behavior without introducing regressions
  • Added comprehensive test coverage for the optimized functions

Testing

  • Added test file test_has_more_than_n_keys.py to verify the optimized function
  • All tests pass, confirming the optimizations work correctly
  • All type checks and lint checks pass

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