Model cache: write each set of sketch keys once, and build the states on threads (#9010)
Problem: every state of a saved model wrote the evaluation key of each sketch before it, so a design of many sketches and many features after them repeated the same map over and over. In the SELENE rover (5,484 features, 2,116 bodies) that was 27 of the 33.5 MB manifest: the manifest hit its 32 MiB limit, the save thinned the cache (#3220) to 2,140 of 5,484 states, and every open evaluated the 3,344 left-out features again. Reading the kept states one after another took a few seconds more. Solution: as for sheet bodies (#6152), the records keep a list of sketch-key sets, each distinct set written once, as the keys it sets and drops relative to the set written before it; a state names its set by place. A thinned model keeps the whole list and counts it once against its budget. The reader counts every set's keys, and each state's, towards MAX_HELD before it copies them (a short record can stand for a large set), then builds the states on threads (kernel::map_on_threads) once the shared records are read. The cache format is now /5: an older cache is a miss and the design is evaluated. SELENE's manifest is 15.9 MB with every state kept; opening it evaluates nothing. Parse and evaluate on opening, release build, median of 5 on a shared machine: 7.36 s -> 1.14 s. The evaluated bodies are identical (inspect.measure of all 2,116 bodies). Claude-Session: https://claude.ai/code/session_013WUFq6QFBqmZjxwaKy2J1M Co-authored-by: Markus Kaltenbrunner <kaltenbrunnermarkus@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
12636b67be
commit
f331a0740b
@@ -147,7 +147,7 @@ SHA-256 of their encoding), and a placed copy of a repeated part (an instance fr
|
||||
a STEP assembly) records the part and its matrix, so it shows that part's display
|
||||
again instead of being meshed on its own.
|
||||
|
||||
`cache/model.json` records `solidcraft-model-cache/4`, the producer revision
|
||||
`cache/model.json` records `solidcraft-model-cache/5`, the producer revision
|
||||
`solidcraft-truck-adapter/3`, the application version, the build (source commit,
|
||||
CPU architecture and OS), the evaluation source (below, with the CPU architecture
|
||||
and OS), the SHA-256 of the exact `document.json` (whose blob references pin every
|
||||
@@ -183,7 +183,10 @@ repeat for longest), each while what it adds still fits: the bodies no state kep
|
||||
so far holds (a body is stored once however many states hold it) and the records
|
||||
of the state, those bodies, their names and sketches. Sheet bodies, like sketches, are
|
||||
written once and named by place in the states (most features leave the sheets as they were); a
|
||||
thinned cache keeps all of them. When the rest of the
|
||||
thinned cache keeps all of them. So are the states' sketch keys (the evaluation key of each
|
||||
sketch before the state): each distinct set is written once, as the keys it sets and drops
|
||||
relative to the set written before it, and a state names its set by place; a thinned cache
|
||||
keeps all of them too. When the rest of the
|
||||
manifest (the bodies' table, the slices) then leaves too little room, the choice
|
||||
is made again within that much less, and the final state alone is always tried.
|
||||
A feature whose state is left out records none. The cache is left out (and the
|
||||
|
||||
Reference in New Issue
Block a user