Skip to content

refactor: removed fnc creation in handler fnc to avoid closure creation#505

Open
exvillager wants to merge 1 commit into
tinyhttp:masterfrom
exvillager:perf/improve-some-perf
Open

refactor: removed fnc creation in handler fnc to avoid closure creation#505
exvillager wants to merge 1 commit into
tinyhttp:masterfrom
exvillager:perf/improve-some-perf

Conversation

@exvillager

@exvillager exvillager commented Jul 12, 2026

Copy link
Copy Markdown

Description

Refactors request handling in the App class so the loop and handle closures are no longer allocated on every incoming request.
code extracted into private methods (#loop and #handle) with a small explicit state object.

Benefits

  • Reduces per-request closure allocations (2 fewer function objects created per request).

Benchmarks

  • Tested on my machine (Apple Silicon, Node v24.16.0 wrk -t4 -c64 -d10s, hello-world route).
  • throughput is the same as master (~83k req/s on both, within run-to-run noise).
  • and GC counts under a fixed 500k-request load are essentially identical.

PS

  • So this PR doesn't make the performance of the application faster than current code.

@exvillager
exvillager marked this pull request as ready for review July 12, 2026 06:30
@exvillager

Copy link
Copy Markdown
Author

@v1rtl check this PR.
it improves the application performance and tail latency.

@v1rtl

v1rtl commented Jul 16, 2026

Copy link
Copy Markdown
Member
  1. can you squash the biome commit with your code commit
  2. do you have benchmarks showing the performance increase?

@exvillager
exvillager force-pushed the perf/improve-some-perf branch from 37bf754 to fb61483 Compare July 17, 2026 15:14
@exvillager exvillager changed the title perf: removed fnc creation in handler fnc to avoid closure creation refactor: removed fnc creation in handler fnc to avoid closure creation Jul 17, 2026
@exvillager

exvillager commented Jul 17, 2026

Copy link
Copy Markdown
Author
  1. can you squash the biome commit with your code commit
  • Done
  1. do you have benchmarks showing the performance increase?
  • Honestly No , i was wrong in PR making that i claimed it's faster but it's actually same as current code.

Check the PR description i updated about this.

Now it's on you , if you want then you can merge this code or close.

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