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

Deno.core.dispatch uses op name instead of id #6395

Merged
merged 4 commits into from
Jun 21, 2020

Conversation

bartlomieju
Copy link
Member

No description provided.

@@ -1,7 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as util from "../util.ts";
import { core } from "../core.ts";
import { OPS_CACHE } from "../runtime.ts";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes OPS_CACHE indirection which was once problematic place when trying to snapshot ES modules

@@ -1,22 +1,12 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts";
// TODO(bartlomieju): remove this import and maybe lazy-initialize
// OPS_CACHE that belongs only to this module
import { OPS_CACHE } from "../runtime.ts";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Object.assign(window.Deno.core, {
setAsyncHandler,
dispatch: send,
dispatchByName: dispatch,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name to be determined

core/core.js Outdated
@@ -181,9 +183,14 @@ SharedQueue Binary Layout
}
}

function dispatch(opName, control, zeroCopy) {
return send(opsCache[opName], control, zeroCopy);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth to do an assert that resulting opId is not undefined?

Comment on lines +26 to 28
for (const [name, opId] of Object.entries(opsMap)) {
core.setAsyncHandler(opId, getAsyncHandler(name));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async handler registration is the last API bit that's a bit strange IMO and could be structured better

@bartlomieju
Copy link
Member Author

Benchmarks

master

"req_per_sec": {
  "deno_tcp": 63081, 
  "deno_core_http_bench": 82009, 
  "node_proxy_tcp": 34457, 
  "deno_proxy_tcp": 27240, 
  "hyper": 66832, 
  "node_tcp": 72981, 
  "deno_http": 23960, 
  "node_http": 31384, 
  "node_proxy": 3894
}, 
"max_latency": {
  "deno_tcp": 1.02, 
  "deno_core_http_bench": 1.02, 
  "node_proxy_tcp": 1.35, 
  "deno_proxy_tcp": 1.34, 
  "hyper": 0.376, 
  "node_tcp": 0.79, 
  "deno_http": 1.4, 
  "node_http": 2.09, 
  "node_proxy": 7.2
}, 

this PR

"req_per_sec": {
  "deno_tcp": 74296, 
  "deno_core_http_bench": 93082, 
  "node_proxy_tcp": 38774, 
  "deno_proxy_tcp": 31497, 
  "hyper": 80797, 
  "node_tcp": 80303, 
  "deno_http": 27514, 
  "node_http": 36940, 
  "node_proxy": 4729
}, 
"max_latency": {
  "deno_tcp": 0.591, 
  "deno_core_http_bench": 0.86, 
  "node_proxy_tcp": 0.98, 
  "deno_proxy_tcp": 1.18, 
  "hyper": 0.303, 
  "node_tcp": 0.614, 
  "deno_http": 1.06, 
  "node_http": 24.48, 
  "node_proxy": 5.91
}, 

@ry
Copy link
Member

ry commented Jun 20, 2020

Probably need a couple of other samples from benchmarks in order to draw any conclusions. I would suggest doing a release build locally and hitting tools/deno_tcp.ts with wrk manually to get a better sense.

@bartlomieju
Copy link
Member Author

@ry sure, here are better benchmarks

Benchmark:
server - deno run --allow-net tools/deno_tcp.ts
client - wrk -d 20 --latency http://127.0.0.1:4500

v1.1.1

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   137.79us   97.72us   6.48ms   97.76%
    Req/Sec    36.08k     2.20k   37.80k    92.04%
  Latency Distribution
     50%  128.00us
     75%  131.00us
     90%  147.00us
     99%  326.00us
  1443376 requests in 20.10s, 70.20MB read
Requests/sec:  71807.21
Transfer/sec:      3.49MB

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   133.33us   47.72us   3.04ms   96.40%
    Req/Sec    36.75k     1.59k   38.06k    93.78%
  Latency Distribution
     50%  127.00us
     75%  130.00us
     90%  140.00us
     99%  301.00us
  1469653 requests in 20.10s, 71.48MB read
Requests/sec:  73119.47
Transfer/sec:      3.56MB

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   149.73us  224.45us  11.15ms   98.80%
    Req/Sec    35.19k     3.11k   37.26k    90.55%
  Latency Distribution
     50%  131.00us
     75%  133.00us
     90%  150.00us
     99%  403.00us
  1407474 requests in 20.10s, 68.46MB read
Requests/sec:  70020.77
Transfer/sec:      3.41MB

this PR

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   140.56us   89.84us   4.55ms   97.74%
    Req/Sec    35.32k     1.78k   36.81k    93.75%
  Latency Distribution
     50%  132.00us
     75%  134.00us
     90%  146.00us
     99%  326.00us
  1405784 requests in 20.00s, 68.37MB read
Requests/sec:  70289.81
Transfer/sec:      3.42MB

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   139.50us   54.78us   2.65ms   96.30%
    Req/Sec    35.20k     1.77k   36.80k    92.04%
  Latency Distribution
     50%  132.00us
     75%  135.00us
     90%  146.00us
     99%  327.00us
  1407833 requests in 20.10s, 68.47MB read
Requests/sec:  70035.17
Transfer/sec:      3.41MB

Running 20s test @ http://127.0.0.1:4500
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   140.96us  107.73us   7.21ms   98.08%
    Req/Sec    35.38k     1.78k   36.86k    94.03%
  Latency Distribution
     50%  131.00us
     75%  134.00us
     90%  146.00us
     99%  326.00us
  1415349 requests in 20.10s, 68.84MB read
Requests/sec:  70415.77
Transfer/sec:      3.42MB

@bartlomieju bartlomieju requested a review from ry June 21, 2020 13:51
@bartlomieju bartlomieju changed the title [WIP] Deno.core.dispatch uses op name instead of id Deno.core.dispatch uses op name instead of id Jun 21, 2020
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - let's try it. I want to see how the benchmarks look over time, but I think this makes sense.

@bartlomieju bartlomieju merged commit 79adc7b into denoland:master Jun 21, 2020
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