mafintosh / turbo-http

Blazing fast low level http server
MIT License
1k stars 47 forks source link

benchmarks #13

Closed devsnek closed 6 years ago

devsnek commented 6 years ago

i've been using both autocannon and wrk2 to benchmark this library and i'm simply unable to have the following code handle more than ~32,400 requests per second (still a great bump up from node's ~17k).

const BUF = Buffer.from('hello, world');
turbo.createServer((req, res) => {
  res.end(BUF);
});

i would imagine that the changes that were made to the codebase since the first commit may have introduced performance regressions, but if that isn't the case i'm quite curious about your setup that got 100,000 requests per second

devsnek commented 6 years ago

i ran a prof and found the bottleneck seems to be http-parser-js unless i'm reading this wrong

 [Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 1.0% are not shown.

   ticks parent  name
   3428   36.6%  UNKNOWN
   2487   72.5%    LazyCompile: *methods.(anonymous function).createServer http_turbo.js:9:54
   2487  100.0%      LazyCompile: *onhead node_modules/turbo-http/index.js:292:21
   2487  100.0%        LazyCompile: *HTTPParser.HEADER node_modules/http-parser-js/http-parser.js:270:40
   2487  100.0%          LazyCompile: *onread node_modules/turbo-http/index.js:310:21
   2487  100.0%            LazyCompile: *_onread node_modules/turbo-net/lib/connection.js:121:11
     40    1.2%    LazyCompile: *_writeHeader node_modules/turbo-http/index.js:85:16
     40  100.0%      LazyCompile: ~_end node_modules/turbo-http/index.js:227:8
     40  100.0%        LazyCompile: ~end node_modules/turbo-http/index.js:195:7
     40  100.0%          LazyCompile: ~methods.(anonymous function).createServer http_turbo.js:9:54
     40  100.0%            LazyCompile: *onhead node_modules/turbo-http/index.js:292:21
mafintosh commented 6 years ago

I used this branch of autocannon, https://github.com/mafintosh/autocannon/tree/turbo

devsnek commented 6 years ago

@mafintosh using that branch has no statistically significant effect for me :(

mafintosh commented 6 years ago

How much do you get against node core?

devsnek commented 6 years ago

node http: autocannon and wrk2 ~13-17k turbo: autocannon ~27k, wrk2 ~32k

mafintosh commented 6 years ago

Right. Then it might just be a faster computer I tested on

mafintosh commented 6 years ago

If you wanna commit some benchmarks to the repo that'd be cool :)