pool
Classes
Pool
Defined in: tar/src/pool.ts:56
Unpacks tarballs into place.
Unpacking -- inflating, parsing and writing a tarball -- runs on a
PlacementPool of worker threads once an install is large
enough to pay for their boot (see warm), so several packages are
unpacked at once and the main thread stays free for the network and
the graph. Linking a global store entry stays on the main thread; see
placement-worker.ts for the measurement behind that. Until then, and on a
machine with no spare core, it runs as it did before the pool
existed: decompression on libuv's threadpool, the files written
synchronously on the main thread, which is measurably faster than the
async writers (the libuv round trip per file costs more than the IO).
VLT_TAR_SYNC switches that pairing and disables the pool; see the
constant above.
The pool queues placements for its workers and caps the compressed
bytes held between download and unpack. The caller still caps how
many extractions it has in flight: reify does, in
@vltpkg/graph src/reify/index.ts.
Constructors
new Pool()
new Pool(): PoolReturns
Methods
close()
close(): Promise<void>Defined in: tar/src/pool.ts:157
Terminate the placement worker threads, if any were started. The pool works without this -- idle workers do not keep the process alive -- but reify calls it when an install's placement is done, to free the threads promptly.
Returns
Promise<void>
linkFromStore()
linkFromStore(
storeEntry,
target,
opts?): Promise<StoreLinkResult>Defined in: tar/src/pool.ts:131
Hardlink (or copy) a global store entry into target. Resolves
how, with the index, or false on a store miss. See
linkFromStore.
Parameters
| Parameter | Type |
|---|---|
storeEntry | string |
target | string |
opts? | LinkFromStoreOptions |
Returns
Promise<StoreLinkResult>
unpack()
unpack(
tarData,
target,
format?): Promise<void>Defined in: tar/src/pool.ts:69
Provide the tardata to be unpacked, and the location where it's to be placed. Resolves when the tarball has been extracted. See PlacementPool.unpack.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
target | string |
format? | TarballFormat |
Returns
Promise<void>
unpackCacheEntry()
unpackCacheEntry(
file,
target,
format?): Promise<void>Defined in: tar/src/pool.ts:85
Unpack the tarball in the vlt cache entry file, whose first 4
bytes are the big-endian length of the head before the body. On a
worker the file is read there, so the main thread never holds the
body. See PlacementPool.unpackCacheEntry.
Parameters
| Parameter | Type |
|---|---|
file | string |
target | string |
format? | TarballFormat |
Returns
Promise<void>
unpackFile()
unpackFile(
file,
target,
offset,
format?): Promise<void>Defined in: tar/src/pool.ts:107
Same, reading the tarball from a file and skipping offset leading
bytes, so a cache entry is unpacked without loading it into the
registry client's in-memory cache.
Parameters
| Parameter | Type | Default value |
|---|---|---|
file | string | undefined |
target | string | undefined |
offset | number | 0 |
format? | TarballFormat | undefined |
Returns
Promise<void>
unpackToStore()
unpackToStore(
tarData,
dir,
format?): Promise<{
index: StoreIndex;
}>Defined in: tar/src/pool.ts:165
Explode a tarball into dir for the global store. See
unpackToStoreSync.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
dir | string |
format? | TarballFormat |
Returns
Promise<{
index: StoreIndex;
}>
warm()
warm(jobs): Promise<void>Defined in: tar/src/pool.ts:146
Start the unpack workers for an install about to unpack jobs
tarballs, so they boot while the first packages are fetched rather
than on the first placement. Never rejects. See
PlacementPool.warm.
Parameters
| Parameter | Type |
|---|---|
jobs | number |
Returns
Promise<void>