Skip to content

Dev - #22

Merged
erayhanoglu merged 5 commits into
mainfrom
dev
Sep 8, 2026
Merged

Dev#22
erayhanoglu merged 5 commits into
mainfrom
dev

Conversation

@erayhanoglu

Copy link
Copy Markdown
Member

No description provided.

…s in Pool

- release() now invokes the callback even when the resource isn't in the
  pool or is already idle, instead of silently dropping it (releaseAsync()
  could hang forever otherwise).
- close() now rejects any requests still queued instead of discarding them
  without ever calling back.
- _houseKeep() no longer marks the pool CLOSED while a resource creation is
  still in flight, which was leaking a never-destroyed resource.
- _ensureMin() skips scheduling a process.nextTick() entirely when
  min/minIdle are both unset (the default), removing a wasted microtask on
  every single acquire().
- _createResource()/_processNextRequest() properly account for _creating
  and _requestsProcessing when a request has already timed out, instead of
  leaking both counters.
- awaitResult() replaces putil-promisify's promisify.await() on the
  create/destroy/reset/validate paths, attaching both handlers via
  .then(onFulfilled, onRejected) instead of chaining a second promise off
  .catch() - one fewer Promise allocated per call.
Ad hoc benchmark-tests/ script (untyped one-shot loop, no repeats, no
statistics) replaced with a real harness modeled after postgrejs's own
benchmark tool:

- One child process per (library, scenario, run), spawned sequentially,
  using tinybench for latency/throughput sampling.
- 5 scenarios (acquire-release, acquire-release-concurrent,
  queue-contention, create-destroy-churn, validate-on-borrow) comparing
  lightning-pool against generic-pool on an identical simulated resource.
- GC/peak-heap instrumentation via node:perf_hooks + --expose-gc, with a
  periodic forced setImmediate yield (installPeriodicYield in worker.ts) so
  a pool whose hot path resolves entirely through microtasks doesn't read
  back as a misleading gcCount=0/peakHeap=0.
- `npm run bench` (matrix runner, --lib/--scenario/--repeats flags) and
  `npm run bench:report` (regenerate the doc from existing results).
…KS.md

README.md was ~80% API reference (methods/properties/events/enums), pushing
the actual pitch and quick-start below the fold. That reference now lives in
doc/API.md, corrected against the current source along the way:
- Removed `resetOnReturn`, an option that no longer exists.
- Removed acquire()'s `factoryCreateOptions` parameter, which doesn't exist
  either - factory.create(info) is populated by the Pool itself on retries.
- Fixed the `create-error` event name to `error` (payload:
  {requestTime, tries, maxRetries}).
- Documented releaseAsync()/destroyAsync()/closeAsync(), the `terminate` and
  `request-timeout` events, and the exported ResourceState enum - none of
  which were mentioned before.

doc/BENCHMARKS.md is benchmark/report/render-markdown.ts's generated output,
committed so README.md's link to it resolves to real numbers; regenerate
with `npm run bench` or `npm run bench:report`.

The stale root BANCHMARK.md (describing the now-removed benchmark-tests/
tool) is removed - superseded by doc/BENCHMARKS.md.
@erayhanoglu
erayhanoglu merged commit 2c14495 into main Sep 8, 2026
4 of 5 checks passed
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.

1 participant