Skip to content
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

Make buffer.toString("base64") 4x faster #3486

Merged
merged 3 commits into from
Jul 2, 2023
Merged

Conversation

Jarred-Sumner
Copy link
Collaborator

This adds https://github.com/aklomp/base64 as a dependency to Bun, which is the same library that Node uses.

cpu: Apple M1 Max
runtime: bun 0.6.13_debug (arm64-darwin)

benchmark                      time (avg)             (minmax)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer.toString('base64')   40.41 µs/iter    (12.5 µs10.22 ms)  15.58 µs 561.83 µs   1.13 msbun
cpu: Apple M1 Max
runtime: bun 0.6.12 (arm64-darwin)

benchmark                      time (avg)             (minmax)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer.toString('base64')  269.96 µs/iter     (177 µs38.42 ms) 186.92 µs 905.17 µs   3.41 msnode
cpu: Apple M1 Max
runtime: node v20.1.0 (arm64-darwin)

benchmark                      time (avg)             (minmax)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer.toString('base64')  129.44 µs/iter    (22.08 µs6.61 ms)  57.79 µs   1.65 ms   2.02 msdeno
cpu: unknown
runtime: deno 1.34.2 (aarch64-apple-darwin)

benchmark                      time (avg)             (minmax)       p75       p99      p995
----------------------------------------------------------------- -----------------------------
Buffer.toString('base64')   154.7 µs/iter   (36.29 µs12.95 ms) 105.54 µs   1.44 ms   1.91 ms

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

@Jarred-Sumner 5 files with test failures on linux-x64:

  • test/cli/install/bun-run.test.ts
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/node/watch/fs.watch.test.js
  • test/js/web/fetch/fetch-leak.test.js
  • test/js/web/websocket/websocket.test.js

View test output

#a85491844be447df43beb78137255145f6a3bf47

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

@Jarred-Sumner 8 files with test failures on bun-darwin-aarch64:

  • test/cli/install/bun-run.test.ts
  • test/js/bun/net/socket.test.ts
  • test/js/bun/spawn/spawn.test.ts
  • test/js/bun/test/snapshot-tests/__snapshots__/bun-snapshots.test.ts.snap
  • test/js/bun/test/test-test.test.ts
  • test/js/bun/util/error-gc-test.test.js
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/web/websocket/websocket.test.js

View test output

#a85491844be447df43beb78137255145f6a3bf47

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

@Jarred-Sumner 5 files with test failures on linux-x64-baseline:

  • test/cli/install/bun-run.test.ts
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/node/watch/fs.watch.test.js
  • test/js/web/fetch/fetch-leak.test.js
  • test/js/web/websocket/websocket.test.js

View test output

#a85491844be447df43beb78137255145f6a3bf47

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

@Jarred-Sumner 8 files with test failures on bun-darwin-x64-baseline:

  • test/cli/install/bun-run.test.ts
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts
  • test/js/bun/sqlite/sqlite.test.js
  • test/js/bun/util/error-gc-test.test.js
  • test/js/bun/websocket/websocket-server.test.ts
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/timers/setTimeout.test.js
  • test/js/web/websocket/websocket.test.js

View test output

#a85491844be447df43beb78137255145f6a3bf47

@Jarred-Sumner Jarred-Sumner merged commit 6cae6eb into main Jul 2, 2023
15 of 20 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/base64-fixup branch July 2, 2023 03:02
return bigBuffer.toString("base64");
});

// bench("Buffer.from(str, 'base64')", () => {
Copy link

Choose a reason for hiding this comment

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

Why commented out? Useful benchmark!

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.

None yet

2 participants