perf(elasticsearch): cache per-instance tag keys and skip empty param…#8376
perf(elasticsearch): cache per-instance tag keys and skip empty param…#8376BridgeAR wants to merge 3 commits into
Conversation
Overall package sizeSelf size: 5.82 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
|
✨ Fix all issues with BitsAI or with Cursor
|
BenchmarksBenchmark execution time: 2026-05-12 00:32:23 Comparing candidate commit 05fc035 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1734 metrics, 110 unstable metrics. |
rochdev
left a comment
There was a problem hiding this comment.
I'm not a fan of the unnecessary private variables to just store a zero cost string. It's just unneeded complexity. Not blocking on that though but I don't see it as a pattern worth pursuing in other PRs.
974b874 to
62f44f6
Compare
|
Implementation changed in the last rebase, but the test was not updated. Is that an uncovered condition? |
…s stringify
Two related per-call wins on elasticsearch / opensearch spans:
1. `bindStart` set the `${system}.params` tag from
`JSON.stringify(params.querystring || params.query)` on every call.
The elasticsearch / opensearch transports build `params.querystring`
as an empty `{}` object on `client.ping()` and other no-querystring
call paths, so the tag was the literal `"{}"` on every such span.
The stringified result is now gated on `length > 2`; spans without
a real querystring carry no params tag.
2. The four `${this.system}.…` tag keys are cached on the instance at
construction so the hot path stops allocating four template-literal
strings per call. Per-instance rather than module-scope keeps the
`OpenSearchPlugin` subclass's `opensearch.*` prefix intact.
Microbench (V8 13.6 / Node 24.15, n=2 000 000 × 7 trials, drop
best+worst): typical args 99 ns → 96 ns (-3 ns, -3.5%); empty
querystring={} 21 ns → 48 ns (+27 ns, +127%). Production traffic is
dominated by the typical search / index / get path.
62f44f6 to
b098ce1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b098ce173f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de>
Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de>
…s stringify
Two related per-call wins on elasticsearch / opensearch spans:
bindStartranJSON.stringify(params.querystring || params.query)even when both fields were absent, tagging the literal string"undefined"on every span without a query. The stringify is now gated on the presence of either field; spans without a query carry no${system}.paramstag at all.${this.system}.…tag keys are cached on the instance at construction so the hot path stops allocating four template-literal strings per call. Per-instance rather than module-scope keeps theOpenSearchPluginsubclass'sopensearch.*prefix intact.