Rebuild: a lease never waits for prefetching; one-shot hashes

A lease was only granted for a range with spooled chunks, and the
prefetcher kept ranges ahead per active lease: once the spool ran dry a
worker got none and slept 30 s, fewer ranges were leased, fewer
prefetched. Three workers held one lease between them (~50k headers/s).
A lease now takes a spooled range first, else the next planned one
(leased ranges are fetched first; the stream waits).

crypto.hash instead of createHash().update().digest() for file and
release keys: same digests, ~2.5x faster (~4.6% of a worker's time).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-09 03:08:19 +02:00
1 parent 168605148f
commit 9dc0a27bb4
5 files changed
+30 -25

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
import { createHash } from 'node:crypto'
import { hash as digest } from 'node:crypto'
import { looksLikeFilename } from '../headers/file_key.js'
export interface ReleaseIdentity {
@@ -103,7 +103,7 @@ export function namesRelease(remainder: string): boolean {
}
function hash(...parts: (string | number | undefined)[]) {
return createHash('sha1').update(parts.map((p) => p ?? '').join('\n')).digest('hex')
return digest('sha1', parts.map((p) => p ?? '').join('\n'))
}
/**