Closed EdamAme-x closed 2 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 91.69%. Comparing base (
8a8a576
) to head (9028f2f
). Report is 2 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi @EdamAme-x !
It looks awesome! I'd like to know how much this change affects performance. Did you benchmark it? And how much did you reduce the bundle size?
PS.
To benchmark the req/res performance, you can follow the method used in this repo: https://github.com/SaltyAom/bun-http-framework-benchmarkhttps://github.com/SaltyAom/bun-http-framework-benchmark
Revert (4): The bundle size is smaller, but we got strange benchmark results that one index access is slower than multiple index accesses, so I reverted.
runtime: deno 2.0.5 (x86_64-pc-windows-msvc)
benchmark avg (min … max) p75 p99 (min … top 1%)
-------------------------------------- -------------------------------
Once 193.31 ps/iter 195.31 ps ▇ █
(170.90 ps … 70.87 ns) 341.80 ps █▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
Multi 136.00 ps/iter 146.48 ps █
(97.66 ps … 22.39 ns) 219.73 ps ▁▁▁▁█▁▁▁▄▁▁▁▂▁▁▁▂▁▁▁▁
19.34kb => 19.28kb (1kb = 1024b)
gitpod@honojs-hono-0oouxesc90f:/workspace/hono/sandbox$ ls compare -l
total 40
-rw-r--r-- 1 gitpod gitpod 19288 Nov 9 07:09 after.js
-rw-r--r-- 1 gitpod gitpod 19344 Nov 9 07:11 before.js
There was not much change. (+0.3%)
| Framework | Runtime | Average | Ping | Query | Body |
| ---------------- | ------- | ------- | ---------- | ---------- | ---------- |
| after | deno | 41,225.407 | 50,386.78 | 38,903.5 | 34,385.94 |
| before | deno | 41,079.073 | 50,923.38 | 39,116.56 | 33,197.28 |
@EdamAme-x
Have you ever tried to benchmark frameworks on Bun, not only Deno?
I'll benchmark with several approaches.
I measured the performance of router itself using node, bun, and mitata, but did not see any significant performance improvement that we could see.
In Deno sample
clk: ~3.03 GHz
cpu: AMD EPYC 7B13
runtime: deno 2.0.5 (x86_64-unknown-linux-gnu)
benchmark avg (min … max) p75 p99 (min … top 1%)
-------------------------------------- -------------------------------
Before Trie 3.55 µs/iter 3.57 µs ▅ █▅██ ▅
(3.47 µs … 3.70 µs) 3.68 µs ▄▇█▄████▄▄▄█▁▄▇▁▁▁▄▁▁
After Trie 3.51 µs/iter 3.52 µs ▄▆▂█▂▄
(3.45 µs … 3.71 µs) 3.67 µs ▇▅██████▃▃▁▁▁▃▁▁▁▁▁▁▁
@EdamAme-x
Thanks. Anyway, this is a good improvement. I'll merge this now.
https://github.com/honojs/hono/pull/3647/files#diff-bf1549ba9405f87c376d2d338883f54bfeb6a91f40b28e62dd2ce5e9d4edd4e5L66-L69
Related: https://github.com/honojs/hono/pull/3596
https://github.com/honojs/hono/pull/3647/files#diff-bf1549ba9405f87c376d2d338883f54bfeb6a91f40b28e62dd2ce5e9d4edd4e5L85
Object.create(null)
. It is faster and smaller.Node and Bun (8x~ faster)
In Bun, the speed of both is almost the same.
https://github.com/honojs/hono/pull/3647/files#diff-bf1549ba9405f87c376d2d338883f54bfeb6a91f40b28e62dd2ce5e9d4edd4e5L95
4. Multiple index accesses are eliminated and the size is reduced.https://github.com/honojs/hono/pull/3647/files#diff-bf1549ba9405f87c376d2d338883f54bfeb6a91f40b28e62dd2ce5e9d4edd4e5R130https://github.com/honojs/hono/pull/3647/files#diff-bf1549ba9405f87c376d2d338883f54bfeb6a91f40b28e62dd2ce5e9d4edd4e5L178
The author should do the following, if applicable
bun run format:fix && bun run lint:fix
to format the code