-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This bunch of commits help me improve the performance of a http2 server by 8-10%. The benchmarks reports several 1-2% improvements in various areas. PR-URL: #25567 Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
5 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
requests: [100, 1000, 5000], | ||
streams: [1, 10, 20, 40, 100, 200], | ||
clients: [2], | ||
benchmarker: ['h2load'] | ||
}, { flags: ['--no-warnings'] }); | ||
|
||
function main({ requests, streams, clients }) { | ||
const http2 = require('http2'); | ||
const server = http2.createServer(); | ||
server.on('request', (req, res) => { | ||
const out = fs.createReadStream(file); | ||
res.setHeader('content-type', 'text/html'); | ||
out.pipe(res); | ||
out.on('error', (err) => { | ||
res.destroy(); | ||
}); | ||
}); | ||
server.listen(common.PORT, () => { | ||
bench.http({ | ||
path: '/', | ||
requests, | ||
maxConcurrentStreams: streams, | ||
clients, | ||
threads: clients | ||
}, () => { server.close(); }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,11 +64,29 @@ void LibuvStreamWrap::Initialize(Local<Object> target, | |
}; | ||
Local<FunctionTemplate> sw = | ||
FunctionTemplate::New(env->isolate(), is_construct_call_callback); | ||
sw->InstanceTemplate()->SetInternalFieldCount(StreamReq::kStreamReqField + 1); | ||
sw->InstanceTemplate()->SetInternalFieldCount( | ||
StreamReq::kStreamReqField + 1 + 3); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mcollina
Author
Member
|
||
Local<String> wrapString = | ||
FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"); | ||
sw->SetClassName(wrapString); | ||
|
||
// we need to set handle and callback to null, | ||
// so that those fields are created and functions | ||
// do not become megamorphic | ||
// Fields: | ||
// - oncomplete | ||
// - callback | ||
// - handle | ||
sw->InstanceTemplate()->Set( | ||
FIXED_ONE_BYTE_STRING(env->isolate(), "oncomplete"), | ||
v8::Null(env->isolate())); | ||
sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "callback"), | ||
v8::Null(env->isolate())); | ||
sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "handle"), | ||
v8::Null(env->isolate())); | ||
|
||
sw->Inherit(AsyncWrap::GetConstructorTemplate(env)); | ||
|
||
target->Set(env->context(), | ||
wrapString, | ||
sw->GetFunction(env->context()).ToLocalChecked()).FromJust(); | ||
|
@mcollina Do you remember why you did this change? I think it could be undone, right?