From fb8b9c95923b474d8fd82746fd1d5a0981d5d280 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 5 Nov 2024 08:25:28 +0100 Subject: [PATCH 1/8] WIP fix for #14982 --- .../bun-usockets/src/eventing/epoll_kqueue.c | 4 ++-- src/bun.js/bindings/BunJSCEventLoop.cpp | 16 +++++++++++++++- src/bun.js/bindings/ZigGlobalObject.cpp | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/bun-usockets/src/eventing/epoll_kqueue.c b/packages/bun-usockets/src/eventing/epoll_kqueue.c index 9091cef8b7e7b1..8c654b40c51e8b 100644 --- a/packages/bun-usockets/src/eventing/epoll_kqueue.c +++ b/packages/bun-usockets/src/eventing/epoll_kqueue.c @@ -230,7 +230,7 @@ void us_loop_run(struct us_loop_t *loop) { } } -extern int Bun__JSC_onBeforeWait(void*); +extern int Bun__JSC_onBeforeWaitWithTimer(void* vm, int hasTimer); extern void Bun__JSC_onAfterWait(void*); void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout) { @@ -250,7 +250,7 @@ void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout int needs_after_wait = 0; if (loop->data.jsc_vm) { - needs_after_wait = Bun__JSC_onBeforeWait(loop->data.jsc_vm); + needs_after_wait = Bun__JSC_onBeforeWaitWithTimer(loop->data.jsc_vm, 1); } /* Fetch ready polls */ diff --git a/src/bun.js/bindings/BunJSCEventLoop.cpp b/src/bun.js/bindings/BunJSCEventLoop.cpp index 7a3cf95b2a01ee..3669d803fdbbca 100644 --- a/src/bun.js/bindings/BunJSCEventLoop.cpp +++ b/src/bun.js/bindings/BunJSCEventLoop.cpp @@ -2,17 +2,31 @@ #include #include +#include -extern "C" int Bun__JSC_onBeforeWait(JSC::VM* vm) +extern "C" int Bun__JSC_onBeforeWaitWithTimer(JSC::VM* vm, int hasTimer) { if (vm->heap.hasAccess()) { + if (hasTimer) { + // TODO: this should pass the deadline based on the timeout passed to the event loop code. + // So if you have a setTimeout() call thats happening in 2ms, we should never delay 2ms. + // Also, all of the JSRunLoopTimer code should be using our TimerHeap from Zig. + vm->heap.sweeper().doWork(*vm); + } + vm->heap.releaseAccess(); return 1; } return 0; } +extern "C" int Bun__JSC_onBeforeWait(JSC::VM* vm) +{ + return Bun__JSC_onBeforeWaitWithTimer(vm, 0); +} + extern "C" void Bun__JSC_onAfterWait(JSC::VM* vm) { + vm->heap.acquireAccess(); } diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 2d3ea28d4f7485..c53e42bc7e7f38 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -835,6 +835,8 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(void* console_client, WebCore::JSVMClientData::create(&vm, Bun__getVM()); + vm.heap.disableStopIfNecessaryTimer(); + const auto createGlobalObject = [&]() -> Zig::GlobalObject* { if (UNLIKELY(executionContextId > -1)) { auto* structure = Zig::GlobalObject::createStructure(vm); From f80975066ed66ba06b6e7e25fe74e8e65f221d0b Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 22 Nov 2024 13:42:11 -0800 Subject: [PATCH 2/8] Add regression test for #14982 --- test/regression/issue/14982/14982.test.ts | 17 +++++++++++++++++ test/regression/issue/14982/bun.lockb | Bin 0 -> 3481 bytes test/regression/issue/14982/commander-index.ts | 2 ++ test/regression/issue/14982/index.ts | 1 + test/regression/issue/14982/package.json | 14 ++++++++++++++ test/regression/issue/14982/test-test.ts | 8 ++++++++ 6 files changed, 42 insertions(+) create mode 100644 test/regression/issue/14982/14982.test.ts create mode 100755 test/regression/issue/14982/bun.lockb create mode 100644 test/regression/issue/14982/commander-index.ts create mode 100644 test/regression/issue/14982/index.ts create mode 100644 test/regression/issue/14982/package.json create mode 100644 test/regression/issue/14982/test-test.ts diff --git a/test/regression/issue/14982/14982.test.ts b/test/regression/issue/14982/14982.test.ts new file mode 100644 index 00000000000000..32a12930ce6e16 --- /dev/null +++ b/test/regression/issue/14982/14982.test.ts @@ -0,0 +1,17 @@ +import { describe, it, expect } from "bun:test"; +import { bunExe } from "../../../harness"; + +it("does not hang running commander", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), "commander-index.ts", "test"], + cwd: __dirname, + stdout: "pipe", + stderr: "inherit", + }); + + await Promise.race([child.exited, Bun.sleep(1000)]); + expect(child.exitCode).toBe(0); + expect(await new Response(child.stdout).text()).toBe("Test command\n"); +}); + +// TODO: test performance in express and memory usage with abort signals diff --git a/test/regression/issue/14982/bun.lockb b/test/regression/issue/14982/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..5a3c2b1e8c9620cf4fa5ffb2e1acda0bece58782 GIT binary patch literal 3481 zcmd5;dr(wW7{3eagH1qmbxb1`Nm6j{zF=8oUDUx|D642_D(13#SuXC&d+&m5J|G{1 zLJFnfXruW^35S9vt%R1$T+8=x~hwq$wzu)hi z?|k20eo>J!C(FpPXq$|(%fHW3V|#co`fO$)TA6{e+a`pGYS<#_!;{uhNChf7X=s1FK;Ah7-(_YYslKhMDdgd#3cqlBko7(oP4 zC;|_oa2>xs2mTpYO9TWl0DKew9Gp9@e(sH$_EDopoDE5|4H}aA>e0Sq>Qd!J?Qi{V zK2bdA`p9zGoOh!4jZX}+Ya6dk-+XZAu}uZra+~OFqYB5yuA;Jl_Nffr3bJq*NpLSlDp@9r}pdy4Y5Jz8rjX04Z zkKTJ580Jrh?+ookg#V`jpMdc2`ceyLg~mKrea>`}dCgm0*%$Wv-Z&M z?@g$@du!FsGp4oTw~vn>+~iEDZ4G;`p~84O)7+sVvJH#_td-|oq&Yw1W^{VX*j`uRU| zx9%?wPr2j6i|c@{LumVY+EHP>to?SslCs1@u2|{*^+i?9mW+t5kgAT)m!-X&J3usl zeM?zH$(rIp%M)rv7j~6549~D{iHT~xHBW!YhZofoo3QrC;kMKCf@Ejo;@F7+jb-`+ z>9wbm6V_5WhEnn7^W3iQ)Th|xy1iUZeCx6kL*v&q?zI`r? zo>rRFww;?Ks+zv&y&Vx5h2o4H)s2Rv(yk$+q~lsY8)nroL2FX}sN!X1Z`ix$k#R`#3Ka5?R2n@jk^$YTxHN~4#5po=~g zkra~D++xkMhHqGSzdqJALKx~DrtI#R zw7O&&@b)IdHOBr)&eqFPdXf}+C8mb|VAk_qq-7Z+N!wV?V6l)`Zjdt>iqc7xatTYj zD0}u;Nu0!Bq0KgXHWCKBb#{3SEm1$;<~av|fIueFI#o&?Kp#PZYK*>L=v#w&1^tH6 z?@hzwXZL^y?Ta`N7ve#9%!Pb0=HkyS(#}P>@uWgdV5Nl> z6TDH%NrjTsNFYh1y|9LYH}RxWO~(BTCI)gxR>|l6n>T;odb5-@k7CHli#dw187wn6 zhPIh?5=HmbXdb>Af@6(t-f#XAf5dDk6C=Tjo`qi6sl6G#=m5vE6a$=@KT3+yvs3SH z=g+)S6MtN=IHYqJh)84tURXenKrIxHDh0t6I4IW0&<<{bdnyA}Y_wag2AhduayZVx zj+4n4%1pByQ$X4r)?AjfGiI4LMkei^OW_t3P)*M4@&oPO2(UxLVvr>1jdalIX0G^`zNu#@tK+wH_%@ar^+S}6>z3=beFLi%_ literal 0 HcmV?d00001 diff --git a/test/regression/issue/14982/commander-index.ts b/test/regression/issue/14982/commander-index.ts new file mode 100644 index 00000000000000..ea6decfaa99a5b --- /dev/null +++ b/test/regression/issue/14982/commander-index.ts @@ -0,0 +1,2 @@ +import { program } from "commander"; +program.name("test").command("test", "Test command").parse(); diff --git a/test/regression/issue/14982/index.ts b/test/regression/issue/14982/index.ts new file mode 100644 index 00000000000000..f67b2c6454eecf --- /dev/null +++ b/test/regression/issue/14982/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/test/regression/issue/14982/package.json b/test/regression/issue/14982/package.json new file mode 100644 index 00000000000000..ebdf919da99e40 --- /dev/null +++ b/test/regression/issue/14982/package.json @@ -0,0 +1,14 @@ +{ + "name": "14982", + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "commander": "^12.1.0" + } +} \ No newline at end of file diff --git a/test/regression/issue/14982/test-test.ts b/test/regression/issue/14982/test-test.ts new file mode 100644 index 00000000000000..827af4a6629102 --- /dev/null +++ b/test/regression/issue/14982/test-test.ts @@ -0,0 +1,8 @@ +import { Command } from "commander"; + +new Command("test") + .action(() => { + console.log("Test command"); + process.exit(0); + }) + .parse(); From 14b83ace0b6ff7a94098c5764525269ec4b55c1b Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 22 Nov 2024 13:51:46 -0800 Subject: [PATCH 3/8] Revert --- test/regression/issue/14982/14982.test.ts | 17 ----------------- test/regression/issue/14982/bun.lockb | Bin 3481 -> 0 bytes test/regression/issue/14982/commander-index.ts | 2 -- test/regression/issue/14982/index.ts | 1 - test/regression/issue/14982/package.json | 14 -------------- test/regression/issue/14982/test-test.ts | 8 -------- 6 files changed, 42 deletions(-) delete mode 100644 test/regression/issue/14982/14982.test.ts delete mode 100755 test/regression/issue/14982/bun.lockb delete mode 100644 test/regression/issue/14982/commander-index.ts delete mode 100644 test/regression/issue/14982/index.ts delete mode 100644 test/regression/issue/14982/package.json delete mode 100644 test/regression/issue/14982/test-test.ts diff --git a/test/regression/issue/14982/14982.test.ts b/test/regression/issue/14982/14982.test.ts deleted file mode 100644 index 32a12930ce6e16..00000000000000 --- a/test/regression/issue/14982/14982.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { describe, it, expect } from "bun:test"; -import { bunExe } from "../../../harness"; - -it("does not hang running commander", async () => { - const child = Bun.spawn({ - cmd: [bunExe(), "commander-index.ts", "test"], - cwd: __dirname, - stdout: "pipe", - stderr: "inherit", - }); - - await Promise.race([child.exited, Bun.sleep(1000)]); - expect(child.exitCode).toBe(0); - expect(await new Response(child.stdout).text()).toBe("Test command\n"); -}); - -// TODO: test performance in express and memory usage with abort signals diff --git a/test/regression/issue/14982/bun.lockb b/test/regression/issue/14982/bun.lockb deleted file mode 100755 index 5a3c2b1e8c9620cf4fa5ffb2e1acda0bece58782..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3481 zcmd5;dr(wW7{3eagH1qmbxb1`Nm6j{zF=8oUDUx|D642_D(13#SuXC&d+&m5J|G{1 zLJFnfXruW^35S9vt%R1$T+8=x~hwq$wzu)hi z?|k20eo>J!C(FpPXq$|(%fHW3V|#co`fO$)TA6{e+a`pGYS<#_!;{uhNChf7X=s1FK;Ah7-(_YYslKhMDdgd#3cqlBko7(oP4 zC;|_oa2>xs2mTpYO9TWl0DKew9Gp9@e(sH$_EDopoDE5|4H}aA>e0Sq>Qd!J?Qi{V zK2bdA`p9zGoOh!4jZX}+Ya6dk-+XZAu}uZra+~OFqYB5yuA;Jl_Nffr3bJq*NpLSlDp@9r}pdy4Y5Jz8rjX04Z zkKTJ580Jrh?+ookg#V`jpMdc2`ceyLg~mKrea>`}dCgm0*%$Wv-Z&M z?@g$@du!FsGp4oTw~vn>+~iEDZ4G;`p~84O)7+sVvJH#_td-|oq&Yw1W^{VX*j`uRU| zx9%?wPr2j6i|c@{LumVY+EHP>to?SslCs1@u2|{*^+i?9mW+t5kgAT)m!-X&J3usl zeM?zH$(rIp%M)rv7j~6549~D{iHT~xHBW!YhZofoo3QrC;kMKCf@Ejo;@F7+jb-`+ z>9wbm6V_5WhEnn7^W3iQ)Th|xy1iUZeCx6kL*v&q?zI`r? zo>rRFww;?Ks+zv&y&Vx5h2o4H)s2Rv(yk$+q~lsY8)nroL2FX}sN!X1Z`ix$k#R`#3Ka5?R2n@jk^$YTxHN~4#5po=~g zkra~D++xkMhHqGSzdqJALKx~DrtI#R zw7O&&@b)IdHOBr)&eqFPdXf}+C8mb|VAk_qq-7Z+N!wV?V6l)`Zjdt>iqc7xatTYj zD0}u;Nu0!Bq0KgXHWCKBb#{3SEm1$;<~av|fIueFI#o&?Kp#PZYK*>L=v#w&1^tH6 z?@hzwXZL^y?Ta`N7ve#9%!Pb0=HkyS(#}P>@uWgdV5Nl> z6TDH%NrjTsNFYh1y|9LYH}RxWO~(BTCI)gxR>|l6n>T;odb5-@k7CHli#dw187wn6 zhPIh?5=HmbXdb>Af@6(t-f#XAf5dDk6C=Tjo`qi6sl6G#=m5vE6a$=@KT3+yvs3SH z=g+)S6MtN=IHYqJh)84tURXenKrIxHDh0t6I4IW0&<<{bdnyA}Y_wag2AhduayZVx zj+4n4%1pByQ$X4r)?AjfGiI4LMkei^OW_t3P)*M4@&oPO2(UxLVvr>1jdalIX0G^`zNu#@tK+wH_%@ar^+S}6>z3=beFLi%_ diff --git a/test/regression/issue/14982/commander-index.ts b/test/regression/issue/14982/commander-index.ts deleted file mode 100644 index ea6decfaa99a5b..00000000000000 --- a/test/regression/issue/14982/commander-index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { program } from "commander"; -program.name("test").command("test", "Test command").parse(); diff --git a/test/regression/issue/14982/index.ts b/test/regression/issue/14982/index.ts deleted file mode 100644 index f67b2c6454eecf..00000000000000 --- a/test/regression/issue/14982/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello via Bun!"); \ No newline at end of file diff --git a/test/regression/issue/14982/package.json b/test/regression/issue/14982/package.json deleted file mode 100644 index ebdf919da99e40..00000000000000 --- a/test/regression/issue/14982/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "14982", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "commander": "^12.1.0" - } -} \ No newline at end of file diff --git a/test/regression/issue/14982/test-test.ts b/test/regression/issue/14982/test-test.ts deleted file mode 100644 index 827af4a6629102..00000000000000 --- a/test/regression/issue/14982/test-test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Command } from "commander"; - -new Command("test") - .action(() => { - console.log("Test command"); - process.exit(0); - }) - .parse(); From 5cba785a86ec278b9c0f609d1478e6ac6a3ecee4 Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 8 Nov 2024 16:49:27 -0800 Subject: [PATCH 4/8] Better field name in VM.ReleaseHeapAccess --- src/bun.js/bindings/BunJSCEventLoop.cpp | 1 - src/bun.js/bindings/bindings.zig | 9 ++++++--- src/bun.js/module_loader.zig | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bun.js/bindings/BunJSCEventLoop.cpp b/src/bun.js/bindings/BunJSCEventLoop.cpp index 3669d803fdbbca..4e738e72685cbb 100644 --- a/src/bun.js/bindings/BunJSCEventLoop.cpp +++ b/src/bun.js/bindings/BunJSCEventLoop.cpp @@ -27,6 +27,5 @@ extern "C" int Bun__JSC_onBeforeWait(JSC::VM* vm) extern "C" void Bun__JSC_onAfterWait(JSC::VM* vm) { - vm->heap.acquireAccess(); } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index d3ad3bfb0b7687..2e181d028437e8 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -6165,16 +6165,19 @@ pub const VM = extern struct { extern fn Bun__JSC_onAfterWait(vm: *VM) void; pub const ReleaseHeapAccess = struct { vm: *VM, - needs_to_release: bool, + needs_to_acquire: bool, pub fn acquire(this: *const ReleaseHeapAccess) void { - if (this.needs_to_release) { + if (this.needs_to_acquire) { Bun__JSC_onAfterWait(this.vm); } } }; + /// Temporarily give up access to the heap, allowing other work to proceed. Call acquire() on + /// the return value at scope exit. If you did not already have heap access, release and acquire + /// are both safe no-ops. pub fn releaseHeapAccess(vm: *VM) ReleaseHeapAccess { - return .{ .vm = vm, .needs_to_release = Bun__JSC_onBeforeWait(vm) != 0 }; + return .{ .vm = vm, .needs_to_acquire = Bun__JSC_onBeforeWait(vm) != 0 }; } pub fn create(heap_type: HeapType) *VM { diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 2f378ec45a7ae7..cab69e78b71227 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1649,7 +1649,7 @@ pub const ModuleLoader = struct { const heap_access = if (!disable_transpilying) jsc_vm.jsc.releaseHeapAccess() else - JSC.VM.ReleaseHeapAccess{ .vm = jsc_vm.jsc, .needs_to_release = false }; + JSC.VM.ReleaseHeapAccess{ .vm = jsc_vm.jsc, .needs_to_acquire = false }; defer heap_access.acquire(); break :brk jsc_vm.bundler.parseMaybeReturnFileOnly( From aa0b1aefeb4c95f03ba62c5c3b75cfbabb7be671 Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 8 Nov 2024 16:57:26 -0800 Subject: [PATCH 5/8] Kill zombie processes with SIGKILL instead of SIGTERM in test runner --- src/bun.js/javascript.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index ab2d9ec90dee60..e3fdc871532591 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -738,7 +738,7 @@ const AutoKiller = struct { while (this.processes.popOrNull()) |process| { if (!process.key.hasExited()) { log("process.kill {d}", .{process.key.pid}); - count += @as(u32, @intFromBool(process.key.kill(bun.SignalCode.default) == .result)); + count += @as(u32, @intFromBool(process.key.kill(bun.SignalCode.SIGKILL) == .result)); } } return count; From 96da7de5da78763adbc83f9c576c672ca2965d8c Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 8 Nov 2024 19:03:12 -0800 Subject: [PATCH 6/8] WIP regression testing for #14982 --- test/regression/issue/14982/14982.test.ts | 33 ++++++++++++++++++ test/regression/issue/14982/README.md | 15 ++++++++ test/regression/issue/14982/bun.lockb | Bin 0 -> 3481 bytes .../issue/14982/commander-hang.fixture.ts | 3 ++ test/regression/issue/14982/package.json | 14 ++++++++ test/regression/issue/14982/raise.js | 7 ++++ test/regression/issue/14982/raiser.c | 8 +++++ test/regression/issue/14982/test-test.ts | 8 +++++ test/regression/issue/14982/tsconfig.json | 27 ++++++++++++++ 9 files changed, 115 insertions(+) create mode 100644 test/regression/issue/14982/14982.test.ts create mode 100644 test/regression/issue/14982/README.md create mode 100755 test/regression/issue/14982/bun.lockb create mode 100644 test/regression/issue/14982/commander-hang.fixture.ts create mode 100644 test/regression/issue/14982/package.json create mode 100644 test/regression/issue/14982/raise.js create mode 100644 test/regression/issue/14982/raiser.c create mode 100644 test/regression/issue/14982/test-test.ts create mode 100644 test/regression/issue/14982/tsconfig.json diff --git a/test/regression/issue/14982/14982.test.ts b/test/regression/issue/14982/14982.test.ts new file mode 100644 index 00000000000000..ace341acdb6e98 --- /dev/null +++ b/test/regression/issue/14982/14982.test.ts @@ -0,0 +1,33 @@ +import { expect, test, it, describe } from "bun:test"; +import { bunEnv, bunExe } from "../../../harness"; +import { join } from "path"; + +describe("issue 14982", () => { + it("does not hang in commander", async () => { + const process = Bun.spawn([bunExe(), join(__dirname, "commander-hang.fixture.ts"), "test"], { + stdin: "inherit", + stdout: "pipe", + stderr: "inherit", + env: bunEnv, + }); + await process.exited; + expect(process.exitCode).toBe(0); + expect(await new Response(process.stdout).text()).toBe("Test command\n"); + }, 1000); + + it("does not crash when sent SIGUSR1 by a child", async () => { + const process = Bun.spawn([bunExe(), join(__dirname, "raise.js")], { + stdin: "inherit", + stdout: "pipe", + stderr: "inherit", + env: bunEnv, + }); + await process.exited; + expect(process.exitCode).toBe(0); + expect(await new Response(process.stdout).text()).toBe("exited with 0\n"); + }); + + // does not slow down express + // does not slow down fastify + // decreases AbortSignal spam memory usage +}); diff --git a/test/regression/issue/14982/README.md b/test/regression/issue/14982/README.md new file mode 100644 index 00000000000000..ad07fd3a732013 --- /dev/null +++ b/test/regression/issue/14982/README.md @@ -0,0 +1,15 @@ +# 14982 + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.34. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/test/regression/issue/14982/bun.lockb b/test/regression/issue/14982/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..aef5d3a1b60aad5f951277cefbd9068bc6d0b343 GIT binary patch literal 3481 zcmd5;Yfuwc6y895kSZt*j@2STD=IOY2O$KBK|9zNQxJ6U{Rqj11oMF14Ug0+)W@J= zg=(u~9j#(pip7dk9V>%YdCd5#mZ~FYozbeaTE(_F)u~|5-Ruo$Qbc`N5{Cse{BQz}e&EtK?)g>#6JKp&< z>r_eTt&!#O*=wWrO^gq6>Y8q*ZLY02v8ixdcC&Tc=%Vq`6;vkBK9`|eK^6`p0nP_! zB%X#7<7Wa+19*f*gTF|a`8SN;2w`Y{j34PA=6#FtH{i(xz@s{#9D=(w5J^|t3^`#ch2#J2V`l9JH{jig*b!9q_Ck||p2O6vO=ba(n z-J4YTd;5xtbEehe_fAfHvDuYWbA9kz=c=xcQOW|BT^kZ~@qiC6t{XbGFxsSiV`$jS zaqcP7t-I5k%;`hky=031th#ye+qV`})t2rX8{a|B`{_<+>c%6VTk2XnQ&zr2O^X`w zAbacn^6;eJe0XskI9|u0smFy4@{YUx)|AB`c1vaZ*A-W_*fJs>1y^-`y(H!J>;asreq)~qTCT^d&-y1cWzaae})+vlbp_TfeK#3rmcR^N8kx-ikzR3M!k&{URs zFumq%V%%!VVki}FzQpc4syV|f)$d|0k!gxXL3ur+U$@Ds4%C0tCqH+#bh8hyZ=VaJ zrj{nOZD(H?8Qfh}yG$^O8tjvcO_c7uYu8a#kZ&^?~_P{J> z|JfH#-#%FXrG3i*jbnZEh3cr?+jG}03lD9N8RJ_a?1;4Ola#cW)Kh!M>?m3L z0;*Q}5 z?v3HmTs+4SqedJ&eLlla98MGEht4Mo2vM-i(+*0G&E+szjn@A>ly4Z&_%3B!55@NE nQt}x<=QA>{S3Ot4HGrq+e$wc!BM@{iU~>)0@p#&z_x=4Fv^0U0 literal 0 HcmV?d00001 diff --git a/test/regression/issue/14982/commander-hang.fixture.ts b/test/regression/issue/14982/commander-hang.fixture.ts new file mode 100644 index 00000000000000..5430ca3a6bbcfb --- /dev/null +++ b/test/regression/issue/14982/commander-hang.fixture.ts @@ -0,0 +1,3 @@ +import { program } from "commander"; + +program.name("test").command("test", "Test command").parse(); diff --git a/test/regression/issue/14982/package.json b/test/regression/issue/14982/package.json new file mode 100644 index 00000000000000..645f52c271333c --- /dev/null +++ b/test/regression/issue/14982/package.json @@ -0,0 +1,14 @@ +{ + "name": "14982", + "module": "commander-hang.fixture.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "commander": "^12.1.0" + } +} diff --git a/test/regression/issue/14982/raise.js b/test/regression/issue/14982/raise.js new file mode 100644 index 00000000000000..c81fb1fdef9eb9 --- /dev/null +++ b/test/regression/issue/14982/raise.js @@ -0,0 +1,7 @@ +import { spawn } from "node:child_process"; +import { join } from "path"; + +const child = spawn(join(import.meta.dirname, "./raiser"), [], { stdio: "inherit" }); +child.on("close", code => { + console.log(`exited with ${code}`); +}); diff --git a/test/regression/issue/14982/raiser.c b/test/regression/issue/14982/raiser.c new file mode 100644 index 00000000000000..44702688f589e1 --- /dev/null +++ b/test/regression/issue/14982/raiser.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) { + usleep(250000); + kill(getppid(), SIGUSR1); + return 0; +} diff --git a/test/regression/issue/14982/test-test.ts b/test/regression/issue/14982/test-test.ts new file mode 100644 index 00000000000000..827af4a6629102 --- /dev/null +++ b/test/regression/issue/14982/test-test.ts @@ -0,0 +1,8 @@ +import { Command } from "commander"; + +new Command("test") + .action(() => { + console.log("Test command"); + process.exit(0); + }) + .parse(); diff --git a/test/regression/issue/14982/tsconfig.json b/test/regression/issue/14982/tsconfig.json new file mode 100644 index 00000000000000..238655f2ce24cd --- /dev/null +++ b/test/regression/issue/14982/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} From 9ff9e6fff5fc11974a56c3c5d2e670b2deacb196 Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Fri, 8 Nov 2024 19:03:41 -0800 Subject: [PATCH 7/8] Fix compile error --- src/bun.js/javascript.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index e3fdc871532591..9fa1e61858b792 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -738,7 +738,7 @@ const AutoKiller = struct { while (this.processes.popOrNull()) |process| { if (!process.key.hasExited()) { log("process.kill {d}", .{process.key.pid}); - count += @as(u32, @intFromBool(process.key.kill(bun.SignalCode.SIGKILL) == .result)); + count += @as(u32, @intFromBool(process.key.kill(@intFromEnum(bun.SignalCode.SIGKILL)) == .result)); } } return count; From 34d27f059f23010cfcb330c0de715284d3c2aa9d Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Mon, 11 Nov 2024 13:32:50 -0800 Subject: [PATCH 8/8] Test server performance in #14982 regression test --- test/regression/issue/14982/14982.test.ts | 56 +++++++++++++++++- test/regression/issue/14982/bun.lockb | Bin 3481 -> 44341 bytes test/regression/issue/14982/express-server.js | 20 +++++++ .../regression/issue/14982/fastify-server.mjs | 20 +++++++ test/regression/issue/14982/package.json | 4 +- 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 test/regression/issue/14982/express-server.js create mode 100644 test/regression/issue/14982/fastify-server.mjs diff --git a/test/regression/issue/14982/14982.test.ts b/test/regression/issue/14982/14982.test.ts index ace341acdb6e98..cf7f9fc4b3a998 100644 --- a/test/regression/issue/14982/14982.test.ts +++ b/test/regression/issue/14982/14982.test.ts @@ -27,7 +27,59 @@ describe("issue 14982", () => { expect(await new Response(process.stdout).text()).toBe("exited with 0\n"); }); - // does not slow down express - // does not slow down fastify + it("does not slow down express", async () => { + // requests per second with bun 1.1.34 on @190n's work laptop + const baseline = 95939; + + const server = Bun.spawn([bunExe(), join(__dirname, "express-server.js")], { + stdin: "inherit", + stdout: "inherit", + stderr: "inherit", + }); + + // let it start listening + await Bun.sleep(100); + + const oha = Bun.spawn(["oha", "http://localhost:3000", "-j", "-n", "1000000", "-c", "40"], { + stdin: "inherit", + stdout: "pipe", + stderr: "inherit", + }); + + const results = await new Response(oha.stdout).json(); + const rps = results.summary.requestsPerSec; + const slowdownPercent = ((baseline - rps) / baseline) * 100; + expect(slowdownPercent).toBeLessThan(5); + + server.kill(); + }, 15000); + + it("does not slow down fastify", async () => { + // requests per second with bun 1.1.34 on @190n's work laptop + const baseline = 161178; + + const server = Bun.spawn([bunExe(), join(__dirname, "fastify-server.mjs")], { + stdin: "inherit", + stdout: "inherit", + stderr: "inherit", + }); + + // let it start listening + await Bun.sleep(100); + + const oha = Bun.spawn(["oha", "http://localhost:3000", "-j", "-n", "1000000", "-c", "40"], { + stdin: "inherit", + stdout: "pipe", + stderr: "inherit", + }); + + const results = await new Response(oha.stdout).json(); + const rps = results.summary.requestsPerSec; + const slowdownPercent = ((baseline - rps) / baseline) * 100; + expect(slowdownPercent).toBeLessThan(5); + + server.kill(); + }, 15000); + // decreases AbortSignal spam memory usage }); diff --git a/test/regression/issue/14982/bun.lockb b/test/regression/issue/14982/bun.lockb index aef5d3a1b60aad5f951277cefbd9068bc6d0b343..99f013f3cb221fc1cbc0aa051b3b5349cec1c788 100755 GIT binary patch literal 44341 zcmeHw2{={T8}}iSF)F1rC@JBX=Q1>?RFX)gQig+LIEQl%p-HGzD$OKKR6<1&(M+01 zvnI_mm1e2*z3+CG_PsX__kPd+`JU%%J@>uqti9Inx8C)xcdfPe+B-|VuU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pYLEv++LH7j{6{ z9Nfy~gR6P^v*48n{0@e=1IJX-&}<%4I9lXtk2s+;L%j6&@z+)pit8TQ42LU2l-{&f3Q)_7Ud-Wv`C}P z|7IqNOVp6Z_tAjHh$=5?q4}L@0ROwoz=to|TAreXUsM8x@E3&=WdRQ_FIKPsXDi_^ zK*0x^SQm%o%N4NUy+}(_^RGfc@hbrnv*=fnf8Um-z8V$LO8jyaYQm^h?Q41u4WOpq z%*KDZA)=~ZFS7v)ue7Q9U_u1bV2WBqTJYJXGD39YqJuqYM0KT*el}nDg9BR{Ezr?Q z0U;JUC&Um8C-_}NnM=ivDVK4w7m!-Z zIJry3s-78W5D0?+hz8ojzyicfK+Fc^vjb@m0MQ_Mxa)yz%Jl!6%&e0&xi`>z@(vx| z$xj2l8JQ;=28B<~(B+*xHOQNhb@D?XPePA(vTLw6Bm3lu!QGP`LIO75iJ8O5wE^mm zBOH?#bc;-OD%O$%I*8%le+U4vK`#CPRmQ_P`CO^eKU6b zFkE7oY|t%X28+pw`cb`VTWu|w80(A-^bC#kEMRfVnQwFKRp6}MKp9g#BQre{hT9C2 z>$)YlR)A6k5WL_5dei~rDj=BrpxZ!dAv9UESeTw+tl;}60Zc0(z{opUt0!*rn^m4n E05qnDVgLXD diff --git a/test/regression/issue/14982/express-server.js b/test/regression/issue/14982/express-server.js new file mode 100644 index 00000000000000..95eddb1aef9335 --- /dev/null +++ b/test/regression/issue/14982/express-server.js @@ -0,0 +1,20 @@ +const express = require("express"); +const app = express(); + +let count = 0; + +app.get("/", (req, res) => { + count++; + if (count >= 1_000_000) { + setTimeout(() => process.exit(0), 1); + } + + if (count % 50_000 === 0) { + console.log("RSS", (process.memoryUsage.rss() / 1024 / 1024) | 0, "MB"); + } + res.send("Hello World!"); +}); + +app.listen(3000, () => { + console.log("Example app listening on port 3000"); +}); diff --git a/test/regression/issue/14982/fastify-server.mjs b/test/regression/issue/14982/fastify-server.mjs new file mode 100644 index 00000000000000..f1a05a976f23bc --- /dev/null +++ b/test/regression/issue/14982/fastify-server.mjs @@ -0,0 +1,20 @@ +import Fastify from "fastify"; + +let startOfLastRequest = performance.now(); +const fastify = Fastify({}); + +// Declare a route +fastify.get("/", (request, reply) => { + const now = performance.now(); + // if (startOfLastRequest && now - startOfLastRequest > 0.5) { + // console.log("Elapsed", Math.trunc(now - startOfLastRequest), "ms"); + // } + // startOfLastRequest = now; + reply.send({ hello: "world" }); +}); + +// Run the server! +fastify.listen({ port: 3000 }, (err, address) => { + if (err) throw err; + // Server is now listening on ${address} +}); diff --git a/test/regression/issue/14982/package.json b/test/regression/issue/14982/package.json index 645f52c271333c..e9b2f92fac32c6 100644 --- a/test/regression/issue/14982/package.json +++ b/test/regression/issue/14982/package.json @@ -9,6 +9,8 @@ "typescript": "^5.0.0" }, "dependencies": { - "commander": "^12.1.0" + "commander": "^12.1.0", + "express": "^4.21.1", + "fastify": "^5.1.0" } }