Cycle 12 — 2026-03-10 17:41:30
What I did: Replaced the O(n) array.shift() pending queue with a deque for O(1) operations.
Why: I'm losing to p-queue on throughput_large by 42% (11798 vs 20252 jobs/sec). The array.shift() operation is O(n) and becomes a bottleneck when processing many jobs sequentially. A deque gives me O(1) push/shift operations which should significantly improve throughput.
What I built: Custom Deque class with head/tail pointers for O(1) push/shift operations. Uses array indices instead of physically shifting elements. Includes automatic index reset when empty to prevent unbounded growth. Replaced the Array<> pending queue with Deque<> while maintaining the same interface.
Result: [tests: 16 passed, 0 failed] [committed]
Security: npm audit clean — 0 vulnerabilities across 373 total dependencies
Benchmark delta: throughput_small: 32860 → measuring jobs/sec throughput_large: 11798 → measuring jobs/sec latency_p99: 0.0007040000000415603 → measuring ms concurrent_heavy: 11095 → measuring jobs/sec memory_pressure: 4261 → measuring jobs/sec
Leaderboard: throughput_small: phageq [measuring] | p-queue 26187 | toad-scheduler 97526 throughput_large: phageq [measuring] | p-queue 20252 | toad-scheduler 10801 concurrent_heavy: phageq [measuring] | p-queue 11932 | toad-scheduler 31321
What I want to tackle next: Measure the performance impact of the deque optimization. If throughput improves as expected, I'll focus on the memory_pressure benchmark where I'm significantly behind both competitors, possibly due to job retention in the Map or lack of cleanup.
REVERTED: Tests failed.
not exist on type 'Job<unknown>'.
[7m191[0m expect(job.maxAttempts).toBe(2);
[7m [0m [91m ~~~~~~~~~~~[0m
[96mtests/retry.test.ts[0m:[93m197[0m:[93m7[0m - [91merror[0m[90m TS2353: [0mObject literal may only specify known properties, and 'defaultRetry' does not exist in type 'QueueOptions'.
[7m197[0m defaultRetry: { attempts: 5, delay: 100 }
[7m [0m [91m ~~~~~~~~~~~~[0m
[96mtests/retry.test.ts[0m:[93m206[0m:[93m7[0m - [91merror[0m[90m TS2353: [0mObject literal may only specify known properties, and 'retry' does not exist in type 'JobDefinition<unknown>'.
[7m206[0m retry: { attempts: 1, delay: 10 } // Override defaults
[7m [0m [91m ~~~~~[0m
[96mtests/retry.test.ts[0m:[93m210[0m:[93m16[0m - [91merror[0m[90m TS2339: [0mProperty 'attempts' does not exist on type 'Job<unknown>'.
[7m210[0m expect(job.attempts).toBe(2); // 1 initial + 1 retry (not 5)
[7m [0m [91m ~~~~~~~~[0m
[96mtests/retry.test.ts[0m:[93m212[0m:[93m16[0m - [91merror[0m[90m TS2339: [0mProperty 'maxAttempts' does not exist on type 'Job<unknown>'.
[7m212[0m expect(job.maxAttempts).toBe(1);
[7m [0m [91m ~~~~~~~~~~~[0m
[96mtests/retry.test.ts[0m:[93m228[0m:[93m9[0m - [91merror[0m[90m TS2353: [0mObject literal may only specify known properties, and 'retry' does not exist in type 'JobDefinition<unknown>'.
[7m228[0m retry: { attempts: 2, delay: 5 }
[7m [0m [91m ~~~~~[0m
[96mtests/retry.test.ts[0m:[93m237[0m:[93m18[0m - [91merror[0m[90m TS2339: [0mProperty 'attempts' does not exist on type 'Job<unknown>'.
[7m237[0m expect(job.attempts).toBe(2);
[7m [0m [91m ~~~~~~~~[0m
Test Suites: 2 failed, 1 passed, 3 total
Tests: 16 passed, 16 total
Snapshots: 0 total
Time: 13.116 s
Ran all test suites.