brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
449 stars 12 forks source link

perf(optimization): improve req/sec 575% #604

Closed aralroca closed 3 weeks ago

aralroca commented 3 weeks ago

It was only at ~4000 req/sec because many dynamic imports were executed in runtime.

This PR moves some dynamic exports to global variables + adds cache, and improves 575% the req/sec, to ~27.000 req/sec.

There are still many dynamic imports and many optimizations that could bring it close to 100,000 req/sec. But this is a first step, since for 0.1 the target was the route map and the primary features, the optimization is now coming as a target for the 1.0 route map.

Before

> wrk -t12 -c400 -d30s http://localhost:3000
Running 30s test @ http://localhost:3000
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   100.81ms   11.35ms 199.92ms   88.45%
    Req/Sec   328.18     28.23   510.00     89.02%
  117868 requests in 30.09s, 47.89MB read
Requests/sec:   3917.06
Transfer/sec:      1.59MB

Now

> wrk -t12 -c400 -d30s http://localhost:3000
Running 30s test @ http://localhost:3000
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    14.82ms    4.45ms  59.72ms   95.47%
    Req/Sec     2.28k   210.97     2.58k    86.69%
  816361 requests in 30.02s, 331.66MB read
Requests/sec:  27198.12
Transfer/sec:     11.05MB
pkg-pr-new[bot] commented 3 weeks ago

Open in Stackblitz

brisa-adapter-vercel

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-adapter-vercel@604 ```

brisa-tailwindcss

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-tailwindcss@604 ```

brisa

``` bun add https://pkg.pr.new/brisa-build/brisa@604 ```

create-brisa

``` bun add https://pkg.pr.new/brisa-build/brisa/create-brisa@604 ```

www

``` bun add https://pkg.pr.new/brisa-build/brisa/www@604 ```

brisa-pandacss

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-pandacss@604 ```

commit: 038a54a