Skip to content

Comments

perf(es/codegen,es/utils): Migrate to dragonbox_ecma for faster Number::toString#11412

Merged
kdy1 merged 3 commits intoswc-project:mainfrom
magic-akari:perf/use-dragonbox-ecma
Jan 2, 2026
Merged

perf(es/codegen,es/utils): Migrate to dragonbox_ecma for faster Number::toString#11412
kdy1 merged 3 commits intoswc-project:mainfrom
magic-akari:perf/use-dragonbox-ecma

Conversation

@magic-akari
Copy link
Member

Description:

BREAKING CHANGE:

Related issue (if exists):

@changeset-bot
Copy link

changeset-bot bot commented Jan 1, 2026

🦋 Changeset detected

Latest commit: 3737ddd

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 1, 2026

CodSpeed Performance Report

Merging #11412 will not alter performance

Comparing magic-akari:perf/use-dragonbox-ecma (3737ddd) with main (147df2f)

Summary

✅ 138 untouched

@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2026

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (28529864 bytes)

Commit: c50e9b7

@magic-akari magic-akari marked this pull request as ready for review January 1, 2026 18:12
@magic-akari magic-akari requested review from a team as code owners January 1, 2026 18:12
Copilot AI review requested due to automatic review settings January 1, 2026 18:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates from the ryu-js library to the dragonbox_ecma library for converting f64 numbers to JavaScript strings, with the goal of improving performance.

Key Changes:

  • Replaced ryu_js::Buffer with dragonbox_ecma::Buffer in number-to-string conversion code
  • Updated dependencies in swc_ecma_utils and swc_ecma_codegen crates
  • Added dragonbox_ecma version 0.1.0 to workspace dependencies

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/swc_ecma_utils/src/number.rs Updated ToJsString::to_js_string() to use dragonbox_ecma::Buffer instead of ryu_js::Buffer
crates/swc_ecma_codegen/src/lit.rs Updated Print::print() for f64 to use dragonbox_ecma::Buffer instead of ryu_js::Buffer
crates/swc_ecma_utils/Cargo.toml Replaced ryu-js dependency with dragonbox_ecma and reformatted dependency alignment
crates/swc_ecma_codegen/Cargo.toml Replaced ryu-js dependency with dragonbox_ecma, reformatted dependencies, and moved swc_sourcemap to dev-dependencies
Cargo.toml Added dragonbox_ecma = "0.1.0" to workspace dependencies
Cargo.lock Updated lock file to include dragonbox_ecma and remove ryu-js references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kdy1
Copy link
Member

kdy1 commented Jan 2, 2026

Is it really faster in real world workload? I can't find any differences in codspeed

@kdy1 kdy1 added this to the Planned milestone Jan 2, 2026
@magic-akari
Copy link
Member Author

oxc-project/oxc#12821 shows a ~4% codegen improvement when introducing dragonbox, but that result was based on dragonbox v0.0.5. This PR uses v0.1.0 instead, so the results are not directly comparable.

The lack of a visible improvement could be due to a performance regression between versions or simply benchmark noise. I'll open a anther PR that introduces dragonbox at v0.0.5 and re-runs Codespeed for an apples-to-apples comparison.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

@kdy1 kdy1 merged commit b7978cc into swc-project:main Jan 2, 2026
36 checks passed
@magic-akari magic-akari deleted the perf/use-dragonbox-ecma branch January 2, 2026 03:24
@kdy1 kdy1 modified the milestones: Planned, 1.15.10 Jan 20, 2026
@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants