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

perf: optimize client builds #643

Merged
merged 39 commits into from
Nov 30, 2024
Merged

Conversation

aralroca
Copy link
Collaborator

@aralroca aralroca commented Nov 23, 2024

Related #162
Related #556

Finally the PR is ready 🔥

The improvement is not as much as I thought, but it is a good step. Good parts:

  • We already have IIFE implemented with Bun
  • Instead of using multi-build we use only 1 for the client.

Things to look at if we can look at how to improve:

I noticed that currently what subtracts the most milliseconds are the barrel files we create for the Bun builder to have. Currently this is necessary because Bun needs the files to do the build and these files do not exist previously. To understand the actual process; first we build the server and in this step we analyze which Web Components each page needs (or not). Then for all the pages that have Web Components a temporary file is generated with the imports of the web components so that the client build takes them into account as entrypoints and resolves the dependencies and generates the files that the client pages need.

Only if we can avoid this step in the future and create the barrel files directly for use in runtime without the step of going through fopen, then we will improve about 40% of the current time.

Results

hardware used: 23.6.0 arm64 arm
note: all pages have server and client code (because only server without client code are faster)

build-new

Before:

  • 10 pages - 359.07ms
  • 20 pages - 851.17ms
  • 30 pages - 1553.64ms
  • 50 pages - 2405.21ms
  • 80 pages - 4001.66ms
  • 100 pages - 5059.29ms
  • 150 pages - 7578.01ms
  • 300 pages - 14848.46ms
  • 400 pages - 20620.80ms
  • 600 pages - 34038.54ms
  • 1000 pages - 68510.37ms

Now:

  • 10 pages - 335.64ms
  • 20 pages - 723.02ms
  • 30 pages - 1291.97ms
  • 50 pages - 1866.04ms
  • 80 pages - 3262.58ms
  • 100 pages - 4406.63ms
  • 150 pages - 5782.00ms
  • 300 pages - 11660.03ms
  • 400 pages - 17336.42ms
  • 600 pages - 25952.91ms
  • 1000 pages - 45488.65ms

Copy link

pkg-pr-new bot commented Nov 23, 2024

Open in Stackblitz

brisa-adapter-vercel

npm i https://pkg.pr.new/brisa-build/brisa/brisa-adapter-vercel@643

brisa-pandacss

npm i https://pkg.pr.new/brisa-build/brisa/brisa-pandacss@643

brisa-tailwindcss

npm i https://pkg.pr.new/brisa-build/brisa/brisa-tailwindcss@643

brisa

npm i https://pkg.pr.new/brisa-build/brisa@643

create-brisa

npm i https://pkg.pr.new/brisa-build/brisa/create-brisa@643

www

npm i https://pkg.pr.new/brisa-build/brisa/www@643

commit: 496a19a

@aralroca aralroca force-pushed the aralroca/wc-build-optimizations branch 3 times, most recently from ef4d111 to 3b6be47 Compare November 24, 2024 15:30
@aralroca aralroca changed the title perf: optimize client builds [WIP] perf: optimize client builds Nov 28, 2024
@aralroca aralroca force-pushed the aralroca/wc-build-optimizations branch from 5d4950b to 8b6caae Compare November 30, 2024 19:28
@aralroca aralroca marked this pull request as ready for review November 30, 2024 21:59
@aralroca aralroca merged commit 7ff3f90 into canary Nov 30, 2024
5 of 8 checks passed
@aralroca aralroca deleted the aralroca/wc-build-optimizations branch November 30, 2024 22:06
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.

1 participant