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

Bun migration (Performance improvement) #36

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

JarzaCode
Copy link

I have migrated a few core things (packages, tests, scripts, etc) to bun, and everything works as intended. I have noticed performance improvements between the past version and the bun version, and I hope you will consider merging this pull request. I have subsequently updated the instructions in the README file.

Performance improvements:

Tests: Up to ~35x improvement

Bun performance
bun test v1.1.29 (6d43b366)
  
  tests/themes.test.ts:
  ✓ Sanity Check [0.43ms]
  ✓ Themes file exists [0.15ms]
  ✓ Themes file contains JSON [0.12ms]
  ✓ Themes file contains an array [0.07ms]
  ✓ Themes are valid [3.52ms]
  ✓ Default theme exists [0.20ms]
  ✓ No duplicate themes exist [0.47ms]
  
   7 pass
   0 fail
   7 expect() calls
  Ran 7 tests across 1 files. [24.00ms]
  
  real    0m0.031s
  user    0m0.027s
  sys     0m0.014s
PNPM performance
> [email protected] test /workspaces/Metallic
> ava


  ✔ Themes file exists
  ✔ Themes file contains JSON
  ✔ Themes file contains an array
  ✔ Themes are valid
  ✔ Default theme exists
  ✔ No duplicate themes exist
  ─

  6 tests passed
  
  real    0m0.959s
  user    0m0.924s
  sys     0m0.163s

Raw increase:

real    30.93x increase
user   34.33x increase
sys     11.6x increase

Please note that there is an extra test for Bun, so this is not the full extent of optimization

Builds: Up to ~1.76x improvement

Bun performance
$ bun test && tsc && bunx vite build
bun test v1.1.29 (6d43b366)

tests/themes.test.ts:
✓ Sanity Check [0.43ms]
✓ Themes file exists [0.13ms]
✓ Themes file contains JSON [0.11ms]
✓ Themes file contains an array [0.06ms]
✓ Themes are valid [3.81ms]
✓ Default theme exists [0.14ms]
✓ No duplicate themes exist [0.37ms]

 7 pass
 0 fail
 7 expect() calls
Ran 7 tests across 1 files. [21.00ms]
vite v5.4.8 building for production...
<script src="/chemical.js"> in "/index.html" can't be bundled without type="module" attribute

/themes.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 103 modules transformed.
build/index.html                             0.41 kB │ gzip:   0.27 kB
build/assets/khanacademy-DPg78iSg.ico        4.29 kB
build/assets/ultravioletLogo-DWukuK5o.png   20.87 kB
build/assets/scramjetLogo-B-1gqv0s.png      28.38 kB
build/assets/canvas-B_OFxn_m.ico            32.99 kB
build/assets/rammerheadLogo-BEV5SZ6i.png    44.14 kB
build/assets/index-DXWrTaMc.css              9.61 kB │ gzip:   2.86 kB
build/assets/index-BJ2Yn_7q.js             317.02 kB │ gzip: 106.89 kB
✓ built in 1.57s
Generate File to /workspaces/Buntallic/build/themes.css

real    0m4.364s
user    0m7.935s
sys     0m0.577s
PNPM performance
> [email protected] build /workspaces/Metallic
> pnpm run test && tsc && vite build


> [email protected] test /workspaces/Metallic
> ava


  ✔ Themes file exists
  ✔ Themes file contains JSON
  ✔ Themes file contains an array
  ✔ Themes are valid
  ✔ Default theme exists
  ✔ No duplicate themes exist
  ─

  6 tests passed
vite v5.4.2 building for production...
<script src="/chemical.js"> in "/index.html" can't be bundled without type="module" attribute

/themes.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
✓ 103 modules transformed.
build/index.html                             0.41 kB │ gzip:   0.27 kB
build/assets/khanacademy-DPg78iSg.ico        4.29 kB
build/assets/ultravioletLogo-DWukuK5o.png   20.87 kB
build/assets/scramjetLogo-B-1gqv0s.png      28.38 kB
build/assets/canvas-B_OFxn_m.ico            32.99 kB
build/assets/rammerheadLogo-BEV5SZ6i.png    44.14 kB
build/assets/index-DGiLmJMs.css              9.61 kB │ gzip:   2.87 kB
build/assets/index-BQjV9Y7G.js             316.19 kB │ gzip: 106.62 kB
✓ built in 2.10s
Generate File to /workspaces/Metallic/build/themes.css

real    0m7.713s
user    0m9.803s
sys     0m0.765s

Raw increase:

real    1.76x increase
user   1.23x increase
sys     1.32x increase

Starting server: Up to ~70x increase

Bun Performance
$ bun test && bunx tsx index.ts
bun test v1.1.29 (6d43b366)

tests/themes.test.ts:
✓ Sanity Check [0.45ms]
✓ Themes file exists [0.10ms]
✓ Themes file contains JSON [0.10ms]
✓ Themes file contains an array [0.04ms]
✓ Themes are valid [3.76ms]
✓ Default theme exists [0.17ms]
✓ No duplicate themes exist [0.38ms]

 7 pass
 0 fail
 7 expect() calls
Ran 7 tests across 1 files. [22.00ms]
Metallic
- Local: http://localhost:3000

real    0m0.869s
user    0m0.031s
sys     0m0.017s
PNPM performance
> [email protected] start /workspaces/Metallic
> pnpm run test && tsx index.ts


> [email protected] test /workspaces/Metallic
> ava


  ✔ Themes file exists
  ✔ Themes file contains JSON
  ✔ Themes file contains an array
  ✔ Themes are valid
  ✔ Default theme exists
  ✔ No duplicate themes exist
  ─

  6 tests passed
Metallic
- Local: http://localhost:3000

real    0m3.810s
user    0m2.206s
sys     0m0.349s

Raw performance:

real     4.38x increase
user    71.16x increase
sys      20.52x increase

Lighthouse report: Score increase of 20

Bun performance
PNPM performance

Raw performance:

Bun: 95 score
PNPN: 75 score

Network loading time: Up to ~1.85x increase

Bun performance
PNPM performance

Raw performance:

Bun: 1.84 seconds
PNPM: 3.41 seconds

These tests were run on the same computer, on the same internet connection, in the same place, with the same host OS and version. The only things that are different are package versions and the Bun migrations. I once again hope that you will consider these changes and merge them into the repository.

Addresses #35

@JarzaCode
Copy link
Author

JarzaCode commented Oct 8, 2024

@JarzaCode
Copy link
Author

JarzaCode commented Oct 8, 2024

I have made a mistake in my previous benchmarks. I was (by mistake) using tsx instead of executing natively with bun. Another advantage is that bun can run typescript with no middle man. There is an even larger performance improvement, but I don't feel the need to test everything again (Although I have run 1 test and the results are even more shockingly optimized)

@om3ga6400
Copy link

I strongly disapprove of Buntallic because my friend made it

@JarzaCode
Copy link
Author

I strongly disapprove of Buntallic because my friend made it

Is there a reason you don't like it? How can I improve this project before it gets merged? Could you give more feedback, please!

@om3ga6400
Copy link

I strongly disapprove of Buntallic because my friend made it

Is there a reason you don't like it? How can I improve this project before it gets merged? Could you give more feedback, please!

Yes there is a reason I don't like it, the reason I don't like it is because you are the lucky charms mascot.

@JarzaCode
Copy link
Author

I apologize for my friend. I am trying to take this seriously, and hope it will still get merged.

@om3ga6400
Copy link

I apologize for my friend. I am trying to take this seriously, and hope it will still get merged.

nerd

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