#How to make Bun run faster

1 messages · Page 1 of 1 (latest)

gentle magnet
#

Hi, I write a script to solve sudoku using backtracking. I tried to run it with node (18 & 20) and bun (0.8.1) but the time they took almost the same node ~17s, bun ~15s. It isn't fast as Bun doc claimed (x4 faster). Do I need to do anything to make bun run faster?

This is the sudoku:
const sudoku = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 3, 0, 8, 5],
[0, 0, 1, 0, 2, 0, 0, 0, 0],
[0, 0, 0, 5, 0, 7, 0, 0, 0],
[0, 0, 4, 0, 0, 0, 1, 0, 0],
[0, 9, 0, 0, 0, 0, 0, 0, 0],
[5, 0, 0, 0, 0, 0, 0, 7, 3],
[0, 0, 2, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 4, 0, 0, 0, 9],
];

balmy pecan
#

what claim in the docs?

#

(like which one specifically)

gentle magnet
balmy pecan
#

keyword: start

#

its not a global catch-all "everything goes 4x" lol that would have been actually physically revolutionary

gentle magnet
#

thank you 😢

balmy pecan
#

not to say its not faster, you are seeing that 2s speedup there after all, but its not gonna be 4x for most things :P

fair shell
#

if its just js code execution, theres not gonna be much performance (v8 and jsc are REALLY good, and jsc only really has an edge on startup time)
when youre using node and bun apis, like for file io, networking, crypto

that's where you'll find stuff to be faster

balmy pecan
#

at least not without modifying your own code, something to try if you want possibly crazy levels of speedup like that is worker_threads

#

but you need to know to use them properly

#

or they can end up making you slower instead