root
root
#
Scratch — one process's handle on a scratch root, and the layout on disk.
<root>/
objects/<hash>/ immutable value trees
live/<owner>/<n>/ that process's in-progress workspaces
locks/<owner> the process liveness flock
locks/state/<key> one flock per state key
locks/call/<key> one flock per memoized call being computed
locks/resource/<name> one flock per machine-wide resource (``gpu``)
settings.toml
index.sqlite objects, names, pins
hashes.sqlite file_hashes, the stat-keyed hash cache
open.lock the flock one process at a time opens the scratch under
Every process on the machine opening the same root co-operates through the
index and the flocks. Opening is serialized, so an index of an older layout is
migrated or rebuilt once; whatever a dead process left in live/ or pinned
is reclaimed the next time anyone opens the scratch.
Scratch
#
One process's handle on a scratch root; see the module for the layout.
Source code in capturegraph-lib/capturegraph/scratch/root.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
call_locks_dir
property
#
Where the lock of every call being computed lives.
live_root
property
#
Where this process's workspaces live.
locks_dir
property
#
Where every process's liveness lock lives.
objects_dir
property
#
Where every sealed object lives.
resource_locks_dir
property
#
Where the lock of every named resource lives.
state_locks_dir
property
#
Where every state key's lock lives.
__init__(root, *, max_size_gb=None, free_space_ratio=None)
#
Open or create the scratch at root and reclaim what dead processes left.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The scratch directory. |
required |
max_size_gb
|
float | None
|
A hard cap on the cache, persisted into |
None
|
free_space_ratio
|
float | None
|
The fraction of releasable disk the cache may occupy,
persisted into |
None
|
An index of an older layout is migrated in place where the change allows; otherwise the scratch is emptied and rebuilt.
Source code in capturegraph-lib/capturegraph/scratch/root.py
__repr__()
#
close()
#
Release this process's hold: its workspaces, its liveness, its index connections.
evict()
#
hash_tree(path)
#
The merkle hash of the tree at path, remembering file hashes by stat.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
Source code in capturegraph-lib/capturegraph/scratch/root.py
hold(name)
#
live_dir()
#
lock_call(key)
#
The right to compute the call key, waiting for whoever holds it to finish.
lock_resource(name)
#
lock_state(key, timeout_seconds=30.0)
#
Exclusive access to the state key.
Raises:
| Type | Description |
|---|---|
ScratchError
|
If the lock is still held elsewhere after |
Source code in capturegraph-lib/capturegraph/scratch/root.py
memo(key, count=1)
#
What this scratch has for the call key, whose call returns count results.
object_dir(hash)
#
reconcile()
#
Make the index agree with the disk and forget what dead processes held.
The disk is listed and measured outside the index transaction; inside it, an object counts as gone only if its directory is still absent, so a tree another process seals meanwhile is never unindexed.
Source code in capturegraph-lib/capturegraph/scratch/root.py
seal(key, workspace, stems, compute_seconds)
#
Seal workspace/<stem> per stem as the results of the call key, pinned.
Source code in capturegraph-lib/capturegraph/scratch/root.py
verify()
#
Drop every object whose files no longer hash to its name, and return their hashes.