Skip to content

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

@seratch
Copy link
Member

seratch commented Aug 15, 2025

Thanks for sending this pull request. We haven't observed performance issues here, so let us close this PR now.

@seratch seratch closed this Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants