diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/bench/http/deno_http_flash.js | 2 | ||||
-rw-r--r-- | cli/bench/http/deno_http_flash_ops.js | 2 | ||||
-rw-r--r-- | cli/bench/http/deno_http_flash_ops_spawn.js | 16 | ||||
-rw-r--r-- | cli/bench/http/deno_http_flash_spawn.js | 16 | ||||
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 3 |
5 files changed, 37 insertions, 2 deletions
diff --git a/cli/bench/http/deno_http_flash.js b/cli/bench/http/deno_http_flash.js index 7c486f422..4b6a1eb21 100644 --- a/cli/bench/http/deno_http_flash.js +++ b/cli/bench/http/deno_http_flash.js @@ -8,4 +8,4 @@ function handler() { return new Response("Hello World"); } -serve(handler, { hostname, port }); +serve(handler, { hostname, port, reusePort: true }); diff --git a/cli/bench/http/deno_http_flash_ops.js b/cli/bench/http/deno_http_flash_ops.js index 40ca25ff1..970447a42 100644 --- a/cli/bench/http/deno_http_flash_ops.js +++ b/cli/bench/http/deno_http_flash_ops.js @@ -11,7 +11,7 @@ const { } = Deno; const addr = Deno.args[0] || "127.0.0.1:4500"; const [hostname, port] = addr.split(":"); -const serverId = op_flash_serve({ hostname, port }); +const serverId = op_flash_serve({ hostname, port, reuseport: true }); const serverPromise = opAsync("op_flash_drive_server", serverId); const fastOps = op_flash_make_request(); diff --git a/cli/bench/http/deno_http_flash_ops_spawn.js b/cli/bench/http/deno_http_flash_ops_spawn.js new file mode 100644 index 000000000..6ee39a84a --- /dev/null +++ b/cli/bench/http/deno_http_flash_ops_spawn.js @@ -0,0 +1,16 @@ +if (Deno.build.os !== "linux") { + throw new Error("SO_REUSEPORT is only supported on Linux"); +} + +const executable = Deno.execPath(); +const path = new URL("./deno_http_flash_ops.js", import.meta.url).pathname; +// single flash instance runs on ~1.8 cores +const cpus = navigator.hardwareConcurrency / 2; +const processes = new Array(cpus); +for (let i = 0; i < cpus; i++) { + const proc = Deno.run({ + cmd: [executable, "run", "-A", "--unstable", path, Deno.args[0]], + }); + processes.push(proc.status()); +} +await Promise.all(processes); diff --git a/cli/bench/http/deno_http_flash_spawn.js b/cli/bench/http/deno_http_flash_spawn.js new file mode 100644 index 000000000..eb827b34b --- /dev/null +++ b/cli/bench/http/deno_http_flash_spawn.js @@ -0,0 +1,16 @@ +if (Deno.build.os !== "linux") { + throw new Error("SO_REUSEPORT is only supported on Linux"); +} + +const executable = Deno.execPath(); +const path = new URL("./deno_http_flash.js", import.meta.url).pathname; +// single flash instance runs on ~1.8 cores +const cpus = navigator.hardwareConcurrency / 2; +const processes = new Array(cpus); +for (let i = 0; i < cpus; i++) { + const proc = Deno.run({ + cmd: [executable, "run", "-A", "--unstable", path, Deno.args[0]], + }); + processes.push(proc.status()); +} +await Promise.all(processes); diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 98cae94a4..a25c1011e 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1352,6 +1352,9 @@ declare namespace Deno { /** An AbortSignal to close the server and all connections. */ signal?: AbortSignal; + /** Sets SO_REUSEPORT on Linux. */ + reusePort?: boolean; + /** The handler to invoke when route handlers throw an error. */ onError?: (error: unknown) => Response | Promise<Response>; |