Skip to content

perf(downgrader): build map output directly instead of via Object.fromEntries - #94

Merged
dinwwwh merged 1 commit into
mainfrom
claude/project-thread-7aadhr
Oct 24, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/project-thread-7aadhr

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Oct 24, 2026

Copy link
Copy Markdown
Member

Requested by dinwwwh · project thread

What

map in packages/downgrader/src/shared.ts collected [key, value] pairs and then called Object.fromEntries (since #50). It now writes each entry straight into {} with setOwn, the same way convertObject and copy already do. setOwn keeps a __proto__ key as an own property, and key order is unchanged.

The existing __proto__ test in v3.1-to-v3.0.test.ts now also puts an integer key beside __proto__ in a properties map and checks the key order and that the map keeps a normal prototype. It fails if map uses a plain out[key] = converted.

Measurements

Wall time with the JIT, median of shuffled rounds with gc between runs:

  • 3.1 to 3.0: bench doc about −15%, Discord −8%, Figma and GitHub −5%
  • 3.2 to 3.1: bench doc about −20%
  • graph benches (path item chain, reference diamond): same or faster

Output is byte-identical on 67 real docs and 800 fuzzed docs. 254 tests and pnpm run check pass.


Generated by Claude Code

…mEntries

`map` collected `[key, value]` pairs and then called `Object.fromEntries`.
Writing each entry straight into the output object with `setOwn` skips the
pair arrays and the second pass. `setOwn` already keeps a `__proto__` key as
an own property, and key order is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ybYkXeGezZAgSErMANBtg
@dinwwwh dinwwwh self-assigned this Oct 24, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • map builds output directly — packages/downgrader/src/shared.ts now writes each converted entry into a plain Record via setOwn instead of collecting pairs and calling Object.fromEntries, matching the existing convertObject/copy pattern.
  • __proto__ test strengthened — the keeps own __proto__ keys as keys test now also places an integer key beside __proto__ and pins key order (['1','__proto__']) and the normal prototype.

The two paths are equivalent: Object.fromEntries also defines own data properties, so __proto__ was already handled as an own key, and integer-index enumeration order is spec-defined independently of insertion order. out was already a fresh local object, so returning it directly adds no aliasing. No concerns.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@codspeed

codspeed Bot commented Oct 24, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 13.3%

1 warning

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
✅ 17 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ dereferenced diamond, 64 levels 687.3 µs 583.1 µs +17.86%
⚡ dereferenced diamond, 64 levels 1,114.2 µs 987.8 µs +12.8%
⚡ cyclic callback graph in removed webhooks, 8 path items 1.2 ms 1.1 ms +12.39%
⚡ path item $ref chain in removed components, 200 hops 5.7 ms 5.2 ms +10.29%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/project-thread-7aadhr (026d908) with main (d14fb04)

Open in CodSpeed

@dinwwwh
dinwwwh merged commit ee6d272 into main Oct 24, 2026
10 checks passed
@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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