Repository navigation
refactor: simplify scheduling, verify performance and clarify usage - #1
Merged
Merged
Conversation
oe
marked this pull request as ready for review
October 3, 2026 11:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scheduler scans waiting callers after each completion and duplicates task state across queues and caches. This can make individual execution quadratic and leave expired results or failed tasks reusable while unrelated work runs. Each unique task now has one record and shared result Promise, with a cursor for serial queues. Existing batching, waiting, cache, retry, and deferred cache-clearing behavior is preserved.
Changes
Upgrade compatibility
Published file paths (dist/index.js, dist/index.es.js, dist/types.d.ts), CommonJS require/import-equals, default imports with esModuleInterop, exported strategy types, and structural public instance types are retained and checked against the real packed artifact. CI now includes that package-level consumer check.
API signatures remain available, but identical behavior cannot be guaranteed for users relying on 1.0.1 bugs. Single-task failures now reject; parallel batches really execute in parallel; serial mode respects batch size; opaque-object identity and equality boundaries are corrected; TTL and retries take effect while unrelated work runs. docs/upgrading.md lists the changes and configuration adjustments. Merge/release is pending the user's decision on these observable corrections.
Validation
The benchmark compares against pre-refactor commit f2e07d2 on the same runtime. Local Node 24 measurements for 1,000 unique tasks: individual execution 13.789 → 1.609 ms, overlapping requests 18.543 → 3.040 ms, serial execution 13.226 → 1.965 ms. Individual execution key calls fall from 508,500 to 2,000 for 2,000 submitted items. Hot-cache individual requests measured 0.109 → 0.192 ms per 1,000 requests. Timings are diagnostic, not portable performance guarantees or CI thresholds.
Boundaries
Arrays still represent multiple tasks. maxBatchCount is a batch size, not a global parallel concurrency limit. Unlimited caching and lazy cleanup remain available. npm run test:package verifies the packed consumer interfaces with skipLibCheck disabled. The npm version remains 1.0.1; the changelog and README identify unpublished changes. This PR does not merge or publish the package.