vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • clonefile
    • link-tree
    • index
    • placement-pool
    • placement-worker
    • pool
    • Reference
    • store-entry
    • store-index
    • unpack
  • Classes
  • Pool
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/tar
  6. /
  7. pool

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()
TypeScript
new Pool(): Pool
Returns

Pool

Methods

close()
TypeScript
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()
TypeScript
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
ParameterType
storeEntrystring
targetstring
opts?LinkFromStoreOptions
Returns

Promise<StoreLinkResult>

unpack()
TypeScript
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
ParameterType
tarDataBuffer
targetstring
format?TarballFormat
Returns

Promise<void>

unpackCacheEntry()
TypeScript
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
ParameterType
filestring
targetstring
format?TarballFormat
Returns

Promise<void>

unpackFile()
TypeScript
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
ParameterTypeDefault value
filestringundefined
targetstringundefined
offsetnumber0
format?TarballFormatundefined
Returns

Promise<void>

unpackToStore()
TypeScript
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
ParameterType
tarDataBuffer
dirstring
format?TarballFormat
Returns

Promise<{ index: StoreIndex; }>

warm()
TypeScript
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
ParameterType
jobsnumber
Returns

Promise<void>


Previousplacement-workerNextReference

On this page

  • Classes
  • Pool

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now