---
title: "@vltpkg/tar: pool — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/tar/pool"
image: "https://docs.vlt.io/og/client/api-reference/tar/pool"
lang: "en"
---

# 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](https://docs.vlt.io/client/api-reference/tar/placement-pool.md#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()

```ts
new Pool(): Pool
```

###### Returns

[`Pool`](https://docs.vlt.io/client/api-reference/tar/pool.md#pool)

#### Methods

##### close()

```ts
close(): Promise<void>
```

Defined in: tar/src/pool.ts:162

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()

```ts
linkFromStore(
   storeEntry, 
   target, 
opts?): Promise<StoreLinkResult>
```

Defined in: tar/src/pool.ts:136

Hardlink (or copy) a global store entry into `target`. Resolves how, with the index, or false on a store miss. See [linkFromStore](https://docs.vlt.io/client/api-reference/tar/link-tree.md#linkfromstore).

###### Parameters

| Parameter    | Type                                                                                                     |
| ------------ | -------------------------------------------------------------------------------------------------------- |
| `storeEntry` | `string`                                                                                                 |
| `target`     | `string`                                                                                                 |
| `opts`?      | [`LinkFromStoreOptions`](https://docs.vlt.io/client/api-reference/tar/link-tree.md#linkfromstoreoptions) |

###### Returns

`Promise`<[`StoreLinkResult`](https://docs.vlt.io/client/api-reference/tar/link-tree.md#storelinkresult)>

##### unpack()

```ts
unpack(
   tarData, 
   target, 
   format?, 
path?): Promise<void>
```

Defined in: tar/src/pool.ts:70

Provide the tardata to be unpacked, and the location where it's to be placed. Resolves when the tarball has been extracted. `path`: only that dir of the tarball's root dir, see [unpack](https://docs.vlt.io/client/api-reference/tar/unpack.md#unpack). See [PlacementPool.unpack](https://docs.vlt.io/client/api-reference/tar/placement-pool.md#unpack).

###### Parameters

| Parameter | Type                                                                                          |
| --------- | --------------------------------------------------------------------------------------------- |
| `tarData` | `Buffer`                                                                                      |
| `target`  | `string`                                                                                      |
| `format`? | [`TarballFormat`](https://docs.vlt.io/client/api-reference/tar/module_index.md#tarballformat) |
| `path`?   | `string`                                                                                      |

###### Returns

`Promise`<`void`>

##### unpackCacheEntry()

```ts
unpackCacheEntry(
   file, 
   target, 
   format?, 
path?): Promise<void>
```

Defined in: tar/src/pool.ts:88

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. `path` as in [unpack](https://docs.vlt.io/client/api-reference/tar/unpack.md#unpack). See [PlacementPool.unpackCacheEntry](https://docs.vlt.io/client/api-reference/tar/placement-pool.md#unpackcacheentry).

###### Parameters

| Parameter | Type                                                                                          |
| --------- | --------------------------------------------------------------------------------------------- |
| `file`    | `string`                                                                                      |
| `target`  | `string`                                                                                      |
| `format`? | [`TarballFormat`](https://docs.vlt.io/client/api-reference/tar/module_index.md#tarballformat) |
| `path`?   | `string`                                                                                      |

###### Returns

`Promise`<`void`>

##### unpackFile()

```ts
unpackFile(
   file, 
   target, 
   offset, 
format?): Promise<void>
```

Defined in: tar/src/pool.ts:112

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`](https://docs.vlt.io/client/api-reference/tar/module_index.md#tarballformat) | `undefined`   |

###### Returns

`Promise`<`void`>

##### unpackToStore()

```ts
unpackToStore(
   tarData, 
   dir, 
   format?): Promise<{
  index: StoreIndex;
}>
```

Defined in: tar/src/pool.ts:170

Explode a tarball into `dir` for the global store. See [unpackToStoreSync](https://docs.vlt.io/client/api-reference/tar/unpack.md#unpacktostoresync).

###### Parameters

| Parameter | Type                                                                                          |
| --------- | --------------------------------------------------------------------------------------------- |
| `tarData` | `Buffer`                                                                                      |
| `dir`     | `string`                                                                                      |
| `format`? | [`TarballFormat`](https://docs.vlt.io/client/api-reference/tar/module_index.md#tarballformat) |

###### Returns

`Promise`<{ `index`: [`StoreIndex`](https://docs.vlt.io/client/api-reference/tar/store-index.md#storeindex); }>

##### warm()

```ts
warm(jobs): Promise<void>
```

Defined in: tar/src/pool.ts:151

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](https://docs.vlt.io/client/api-reference/tar/placement-pool.md#warm).

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `jobs`    | `number` |

###### Returns

`Promise`<`void`>
