summaryrefslogtreecommitdiff
path: root/cli/bench/http
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-09-28 10:46:29 -0700
committerGitHub <noreply@github.com>2022-09-28 23:16:29 +0530
commite64af6260a512a9e6eaed8bc8c48f0222c39afb2 (patch)
tree2471772b0a9f18e61fd0e8c4b2140fb2556c5e5e /cli/bench/http
parentd677ba67f50e5edb0491d8ed1e4171473d662081 (diff)
feat(ext/flash): add `reuseport` option on Linux (#16022)
Diffstat (limited to 'cli/bench/http')
-rw-r--r--cli/bench/http/deno_http_flash.js2
-rw-r--r--cli/bench/http/deno_http_flash_ops.js2
-rw-r--r--cli/bench/http/deno_http_flash_ops_spawn.js16
-rw-r--r--cli/bench/http/deno_http_flash_spawn.js16
4 files changed, 34 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);