Context framework

Configuration options for TensorStore drivers are specified using a context framework, which allows resources such as cache pools, concurrent execution pools, and authentication credentials to be specified using JSON in a way that allows sharing of resources by multiple TensorStore drivers.

Context JSON Schema

A context JSON object is a mapping of resource identifiers to Context resource specifications.

object with members:

<resource-type>

Overrides the default resource for the given <resource-type>, which must be a supported resource type.

<resource-type>#<id>

Defines a resource with identifier <id> of the given <resource-type>. The resource specification must be compatible with <resource-type>.

Example
{ 
  "cache_pool": {"total_bytes_limit": 10000000},
  "cache_pool#remote": {"total_bytes_limit": 100000000},
  "data_copy_concurrency": {"limit": 8}
}

Context resource JSON Schema

object | string | null

Specifies a context resource of a particular <resource-type>.

One of:
  • object

    Specifies the resource directly. All members are specific to the particular <resource-type>.

  • string

    References another resource of the same type in the current or parent context using the syntax “<resource-type>” or “<resource-type>#<id>”, where <resource-type> matches the type of this resource.

  • null

    Specifies a new instance of the default resource of the given <resource-type>. Only valid within a Context specification.

cache_pool context resource JSON Schema

Specifies the size of an in-memory Least Recently Used (LRU) cache. Each cache_pool resource specifies a separate memory pool.

object with members:

total_bytes_limit
integer [0, ∞) (default is 0)

Soft limit on the total number of bytes in the cache. The least-recently used data that is not in use is evicted from the cache when this limit is reached.

queued_for_writeback_bytes_limit
integer [0, ∞)

Soft limit on the total number of bytes of data pending writeback. Writeback is initated on the least-recently used data that is pending writeback when this limit is reached. Defaults to half of total_bytes_limit.

data_copy_concurrency context resource JSON Schema

Specifies a limit on the number of CPU cores used concurrently for data copying/encoding/decoding.

object with members:

limit
integer [1, ∞) | “shared” (default is “shared”)

The maximum number of CPU cores that may be used. If the special value of “shared” is specified, a shared global limit equal to the number of CPU cores/threads available applies.

file_io_concurrency context resource JSON Schema

Specifies a limit on the number of concurrently local filesystem I/O operations.

object with members:

limit
integer [1, ∞) | “shared” (default is “shared”)

The maximum number of concurrent operations. If the special value of “shared” is specified, a shared global limit equal to the number of CPU cores/threads available (or 4 if there are fewer than 4 cores/threads available) applies.