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

Update Hono (bun) impl. for 20% speed boost #59

Open
redbar0n opened this issue Jan 11, 2024 · 9 comments
Open

Update Hono (bun) impl. for 20% speed boost #59

redbar0n opened this issue Jan 11, 2024 · 9 comments

Comments

@redbar0n
Copy link

For example, Hono on Bun looks like it performs badly. But just go to src/bun/hono.ts and change the export to export default { ...app, host: '127.0.0.1' } (instead of export default app) for an instant 20% speed boost that puts it right up, near the top.

according to hattipjs/hattip#114 (comment)

@redbar0n
Copy link
Author

redbar0n commented Mar 12, 2024

Benchmarks should use 127.0.0.1 (IPv4) instead of the name 'localhost', due to potential IPv6 overhead or conflict: don't use localhost (intermediate) anthony explains (4 min).

@SaltyAom
Copy link
Owner

SaltyAom commented Mar 18, 2024

I agree with the benchmark of 127.0.0.1 benchmark part, but disagree with the hattip part:

For example, Hono on Bun looks like it performs badly. But just go to src/bun/hono.ts and change the export to export default { ...app, host: '127.0.0.1' } (instead of export default app) for an instant 20% speed boost that puts it right up, near the top.

Basically, in any server more complex than hello world app, you are likely going to implemented either reverse proxy, micro-service or load balancing for multiple endpoint, eg. staging:

  • api.stuff.dev
  • staging.api.stuff.dev
  • internal.api.stuff.dev

Setting the host ahead of time rejects all of the above implementation.

Additionally, the 20% speed boost is not only limited to Hono, but Elysia, Stric, Vixeny and most frameworks are going to benefit the speed boost as well since the hostname is known ahead of time, we can just omit the hostname entirely.

But we assume that the API staging or load balancing / reverse proxy will be implemented, that optimization doesn't match the real use case.

@redbar0n
Copy link
Author

@cyco130

@cyco130
Copy link

cyco130 commented Mar 21, 2024

Setting the host ahead of time rejects all of the above implementation.

That was my point actually. When I ran the tests a couple of months ago, some of the tested frameworks assumed a certain host name (vixeny's hasName, stricjs's base etc.) which gave them an unfair advantage. Setting the host gives the same advantage to Hono. You can (and should) also go about the other way and disable those optimizations in those frameworks.

@SaltyAom
Copy link
Owner

Didn't realize Stric and Vixen hardcode basename.
Alright, going to remove the basename and rerun the benchmark right now, thanks.

@redbar0n
Copy link
Author

@SaltyAom Would be awesome if you could update the README with the new bench results. It currently says Tested on 18 Mar 2024 19:30 (GMT+7)

@mimiMonads
Copy link
Contributor

Setting the host ahead of time rejects all of the above implementation.

That was my point actually. When I ran the tests a couple of months ago, some of the tested frameworks assumed a certain host name (vixeny's hasName, stricjs's base etc.) which gave them an unfair advantage. Setting the host gives the same advantage to Hono. You can (and should) also go about the other way and disable those optimizations in those frameworks.

@redbar0n

Hello, I was looking at issues and I stumble upon this conversation, the reason why I added hasName (base.bind in the beta version) is for vixeny-create where I use it as a default point of reference, I'm removing it and I will talk to Reve to see if he can do the same.

It should be fixed by the next benchmark sorry for the trouble xd.

@mimiMonads mimiMonads mentioned this issue Jun 1, 2024
@aquapi
Copy link
Contributor

aquapi commented Jun 1, 2024

@redbar0n Stric was abandoned for a while.
I will remove Stric and add my new tools.

@aquapi
Copy link
Contributor

aquapi commented Jun 1, 2024

#71

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

No branches or pull requests

5 participants