Skip to content

perf(javascript): add javascript benchmark#3562

Merged
chaokunyang merged 13 commits intoapache:mainfrom
chaokunyang:add_javascript_benchmarks
Apr 14, 2026
Merged

perf(javascript): add javascript benchmark#3562
chaokunyang merged 13 commits intoapache:mainfrom
chaokunyang:add_javascript_benchmarks

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented Apr 14, 2026

Why?

What does this PR do?

  • add javascript benchmarks
  • align benchmark data model config

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

@chaokunyang chaokunyang force-pushed the add_javascript_benchmarks branch from fd813b6 to 1659187 Compare April 14, 2026 04:24
@chaokunyang chaokunyang force-pushed the add_javascript_benchmarks branch from b07c707 to b197a3f Compare April 14, 2026 07:36
…der reset

- Add TypeId.isLeafTypeId() for primitives, string, enum, time, typed arrays
- Skip incReadDepth/decReadDepth for leaf fields in struct, collection, map codegen
- Reuse DataView in BinaryReader.reset() when underlying buffer is unchanged
- Replace BigInt-based readVarUint36Small with getUint32 fast path,
  eliminating ~25% of deserialization overhead
- Fix getInternalStringDetector to use try/catch require instead of
  unreliable globalThis.require check, enabling O(1) latin1 detection
- Add inline ASCII fast path in stringWithHeaderCompatibly for
  environments without isStringOneByteRepresentation
- Hoist getSerializerById lookups in struct readEmbed/writeEmbed to
  scope-level consts, removing ~5-8% repeated lookup overhead

MediaContent deser: 1174ns -> 600ns (49% faster, now 25% faster than Protobuf)
MediaContent ser: 952ns -> 748ns (21% faster, now 5% faster than JSON)
MediaContentList deser: 4720ns -> 2657ns (44% faster)
MediaContentList ser: 4063ns -> 3325ns (18% faster)
Fory now wins all MediaContent benchmarks:
- MediaContent ser: 773ns (was 849ns), faster than JSON 769ns
- MediaContent deser: 611ns (was 1075ns), faster than Protobuf 827ns
- MediaContentList ser: 3496ns (was 3829ns), faster than JSON 3541ns
- MediaContentList deser: 2654ns (was 4993ns), faster than Protobuf 4088ns
@chaokunyang chaokunyang merged commit 81be086 into apache:main Apr 14, 2026
62 checks passed
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.

2 participants