-
Notifications
You must be signed in to change notification settings - Fork 938
refactor(opentelemetry-core): simplify parsePairKeyValue() #5885
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
base: main
Are you sure you want to change the base?
refactor(opentelemetry-core): simplify parsePairKeyValue() #5885
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5885 +/- ##
==========================================
- Coverage 95.06% 95.06% -0.01%
==========================================
Files 307 307
Lines 8031 8038 +7
Branches 1627 1629 +2
==========================================
+ Hits 7635 7641 +6
- Misses 396 397 +1
🚀 New features to boost your workflow:
|
I haven't dug into why yet, but the new impl shows to be the same time or slower for me:
Similar on Node.js 24:
FWIW: This is on macos 15.6.1, arm64. |
my results are for node v20.19.1 npm run test:bench
> @opentelemetry/core@2.1.0 test:bench
> node test/performance/benchmark/index.js
parsePairKeyValue simple (old) x 4,692,843 ops/sec ±0.41% (94 runs sampled)
parsePairKeyValue simple (new) x 6,267,494 ops/sec ±0.32% (97 runs sampled)
parsePairKeyValue with metadata (old) x 4,180,132 ops/sec ±0.32% (97 runs sampled)
parsePairKeyValue with metadata (new) x 5,656,792 ops/sec ±0.33% (100 runs sampled)
parsePairKeyValue URI encoded (old) x 4,116,159 ops/sec ±1.15% (98 runs sampled)
parsePairKeyValue URI encoded (new) x 5,144,204 ops/sec ±0.55% (99 runs sampled)
parsePairKeyValue complex (old) x 3,226,162 ops/sec ±0.28% (99 runs sampled)
parsePairKeyValue complex (new) x 4,714,852 ops/sec ±0.27% (99 runs sampled)
node --version
v20.19.1 for node v24.0.2 npm run test:bench
> @opentelemetry/core@2.1.0 test:bench
> node test/performance/benchmark/index.js
parsePairKeyValue simple (old) x 4,786,133 ops/sec ±0.34% (99 runs sampled)
parsePairKeyValue simple (new) x 5,645,059 ops/sec ±0.29% (97 runs sampled)
parsePairKeyValue with metadata (old) x 4,332,720 ops/sec ±0.35% (100 runs sampled)
parsePairKeyValue with metadata (new) x 4,920,477 ops/sec ±0.34% (96 runs sampled)
parsePairKeyValue URI encoded (old) x 4,149,403 ops/sec ±0.30% (97 runs sampled)
parsePairKeyValue URI encoded (new) x 4,647,395 ops/sec ±0.42% (100 runs sampled)
parsePairKeyValue complex (old) x 3,416,122 ops/sec ±0.33% (99 runs sampled)
parsePairKeyValue complex (new) x 4,128,169 ops/sec ±0.33% (98 runs sampled)
node --version
v24.0.2 This is on MacOS 15.7.1 with M2 chip. Could it be related to the chip? |
@david-luna Not sure if this due to chip. But for me refactored function always shows better runtime. |
Which problem is this PR solving?
While analysing our application CPU profile, we found

parsePairKeyValue
from @opentelemetry/core is one of the hot function.Fixes # (issue)
Short description of the changes
Refactor the
parsePairKeyValue
function to simplify the computationsType of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
A Benchmark test to compare the Older and newer implementation
Checklist: