Bun vs Node Benchmark - no one cares about speed as much as your CI does
grifel.dev
grifel.dev
That said, it was a tiny and simple test set[1]. It may not be ready yet for more complex tests, as the docs warn[2]:
> You've never seen a JavaScript test runner this fast (or incomplete).
[1] https://github.com/drifting-in-space/driftdb/blob/main/js-pk...
[2] https://bun.sh/
We do support this yes. With what we call background jobs. Each test runner also comes with a dedicated docker server for running additional services (db, etc). It’s an experimental/new feature though and I haven’t properly figured out how to charge for it.
In the happy case while the worker isn’t running tests the background job should be consuming very little resources.. but we can’t rely on that (and also some people will inevitably try to mine crypto) so figuring out how to make sure the workers aren’t hogging the cpu between test runs has prevented me from broadcasting the existence of the feature, it is there though.
Or is there something else going on?
bun:test is fast mostly because it’s integrated deeply into the runtime. Other test runners typically have to mutate globals and spend a lot of time setting up the environment and tearing it down. Also, expect() in bun:test is something like 10x faster[1] than in vitest (100x jest) because it’s written in native code.
Test runners involve a lot of polymorphism which means JS doesn’t get JIT’d much — in cases like that, writing in native is much faster.
Another factor is transpilation time. bun:test supports TypeScript and JSX without plugins and bun’s transpiler is very fast
[1]: https://twitter.com/jarredsumner/status/1595681235606585346?...
1. JSC rather than V8
2. Built in APIs. A lot of nodes APIs are implemented in JS and for this reason (or simply because they’re not well optimised), they run more slowly than Bun’s implementation.
3. Bun also has a highly optimised built in test runner
JSC vs V8 is interesting... I'd like to see something like tsc compile times for real projects compared. And then again against something like SWC (rust impl) :) I doubt we'll switch to bun any time soon for prod runtime, but for speeding up tsc/lint/babel/etc, sure!
Anyway. Last I checked Bun still handily beats SWC (and ESBuild) on basically everything, and beats Node on tons (all?) of runtime metrics. Perf has been its foundational principle from the start, and every aspect of what’s under test in the article has been specifically mentioned as optimization targets by Bun’s creator. You’ll find many of your questions answered on his Twitter[1].
One thing I think is worth adding is that Bun’s perf obsession has been percolating a lot of optimizations upstream to WebKit/JSC. So even if you don’t ever adopt Bun as a server runtime, you or your users are likely benefiting from those contributions on the client.
1: https://twitter.com/jarredsumner?s=21&t=ZMU7ao_SpJj349QDow0M...
But the call time had gone north of 1 second so there was a lot of friction to adding more questions. I subsequently fixed some dumb bootstrapping code to the tune of ~250 ms, which would have been enough to add all of our current apps to the tool, but what really helped was using worker threads knowing the number of environments to check was finite. We only needed k threads so we could eat startup time entirely.
Bun is also faster. If you added my fix and used Bun, you could use forking to cover cases that are O(m) instead of O(k). (Typically k << m < n when doing orders).
What did you check? Bun only has basic transpiring currently. I can't imagine what "everything" is, and without bundling, minification, and down-transpiling support I don't see how any meaningful project could have been tested on.
> Bun’s perf obsession has been percolating a lot of optimizations upstream to WebKit/JSC
Source? AFAIK claiming either "bun devs made a lot of JSC perf optimization PRs" or "bun devs pointed perf hot spots to JSC devs" would be incorrect, but I'd love to learn otherwise.
Yeah, build/bundling use cases have lagged in priority. I’ll rephrase “everything” as “every transpiling use case”.
> Source? AFAIK claiming either "bun devs made a lot of JSC perf optimization PRs" or "bun devs pointed perf hot spots to JSC devs" would be incorrect
Jarred’s Twitter has been frequently highlighting these contributions. This seems like a weird thing to object to if you’re so familiar with the project!
Heads up for the author: the dark theme seems to be handling the tables incorrectly (keeping the tables light but inverting the text to become nearly white).
When it comes to demo and bun then i suggest focusing on deno until bun hits stable release. It's still rough around the edges.
A Fastify server app can easily serve thousands of reqs/s.
https://www.fastify.io/benchmarks/
The whole StackExchange network serves on average 50 page views per second.
EDIT: just tested on the eslint codebase:
cold (nothing installed, no cache): bun: 1.53s, pnpm: 8.25s, npm: 25s
hot (already installed, noop): bun: 218ms, pnpm: 1300ms, npm: 1230ms
Webpack 5 is probably the last version. Not my words, but from its main author. Vite is the new de facto bundler which uses EsBuild (written in Go).
I've swapped much of my usage of npm over to bun. I still work on projects where nobody else is using bun, but I can run `bun install` instead of `npm install` and `bun run` instead of `npm run` and these run probably 100x faster.
Except that Bun is not going to be able to do what esbuild is doing because Go and other languages are in another league regarding perf.
esbuild is a javascript transpiler. it transpiles typescript into javascript that v8 or another js engine can run. it's written in go which is the main reason it's faster than pure js transpilers like babel. were you thinking that esbuild is for go code? i'm confused
bun is a combined javascript transpiler & runtime & test runner & package manager. it improves performance of many things:
- startup time including transpiling code and resolving modules and initializing the javascript vm - installing packages - running tests
it can also improve runtime performance (it is faster at basically every bit of the node api it covers & it has its own versions of some things like http servers that can have better performance than the node APIs)
switching your project to rust would improve runtime performance, but would make it slower to run tests & compile the project & use an ide language server & …
i haven't used go but i've heard it's fast to compile & has better runtime performance than js
Got a reference or specifics on that one?
FWIW the presenter is employed at Vercel on building Turbopack, which is presented as the "webpack successor" - so I'm quite sure either way he wouldn't agree with your take on esbuild being the future ;)
The Vite part I added it myself. Sorry if that wasn't clear.
Regarding TurboPack, we'll see. So far it's not very popular outside of Next. SvelteKit uses Vite, even though Vercel is paying for two people full time working on it.
Culture difference behind the misinterpretation maybe? The lack of self-inflation, exaggerated confidence and exceptionalism we might expect from Americanized presenters shouldn't be taken for insecurity or doubt ;)
I'd listen to what they say at face-value rather than trying to read the lines applying the wrong lens.
> Regarding TurboPack, we'll see. So far it's not very popular outside of Next.
It's very early still, in alpha, and isn't recommended for production use outside of Next, where most of the focus on integration and tooling has been so far AFAIK.
Basic examples:
- Latency/processing (which suffers as req/s grows or peaks)
- Memory usage (idle, at peak)
- Startup time (one-off jobs, serverless cold boot)
The "thousands of req/s" benchmarks are often unrealistic - either super simple (the benchmark you linked serves a static tiny JSON payload) or hyper optimized and not representing a run-of-the-mill webserver.
A hello world Fastify project can get you into the 20k reqs per second. On the same hardware with a real project you probably will get a couple thousands which is more than enough to satisfy 99% of projects.
There are few areas of software where people will obstruct efforts before and support them after quite as much as CI. The biggest is probably software process maturity, where people have to see a scary production issue evaporate into the run book before they “get it”. Build pipeline maturity is solidly in third place, sometimes second.
bun, deno, esbuild, swc etc. can parse the syntax, but they chuck the TS (they probably don't even add it to the AST, but I haven't checked).
Keeping up with syntax is very doable. It doesn't change often, and updating the parser when it does isn't much work.
There are some past/ongoing projects[1][2] to create type checkers faster than tsc, but they aren't going to reach full parity and probably don't plan on keeping up with language features.