Repository navigation
Conversation
…when it has one The Cloud kept every call an engine reported returning one of its entries, one per request digest. A request digest names one session's call when the call's receiver is that session's, so a term every session makes, such as a module's type definition over the module's content, gained a call each session, thousands on one entry. The calls of one term are one call to the cache, which matches a call by its term, and a bundle sends one of them; a local cache adds no second term of a term it has. An entry now keeps one call of each term: a call of a term it keeps a call of is not kept, unless the kept call names an input the Cloud stores no record of, which no bundle can place, and the new call doesn't: the new call then replaces it, and the term becomes one a bundle can send. The entry still takes every call's expiry. A replaced call is forgotten with its input index. The stamp cause for a call of an old term goes, since such a call is no longer kept. On a recorded store this keeps 43,971 of 77,416 kept calls. A recipient that holds another stored input of the term, and not the kept call's, now gets the kept call's input with it: rebuilding every set of that store with the term rule, sets carry 0.58% more records and 0.39% more bytes in all, at most 8.3% more records in one set, and no set loses a term. Keeping one call for each distinct stored input instead would keep more and still grow with every session whose input is stored. A set's own call of a term may now be the one not kept, so a bundle for a recipient that names its check's call must find the term by the call's term too: the term rule's test names B's term, as the service records it. Signed-off-by: Erik Sipsma <[email protected]>
…m it joined (failing first) An entry keeps one call of each term as calls arrive, but two calls kept as two terms become one term when their inputs' classes are joined later, as when a receiver's content is taught after a call on it was kept. Both stay: nothing looks at an entry's calls again but the next call kept on it. The test keeps B's call while the Cloud knows no class of B's receiver, then teaches B's receiver into A's class, and keeps a call of another term on the entry: it expects A's call and the other, and B's dropped. Today all three stay. Signed-off-by: Erik Sipsma <[email protected]>
…oined Two calls an entry kept as two terms are one term once their inputs' classes are joined, as when a receiver's content is taught after a call on it was kept, and the entry kept them both: a bundle sends one of them, and the other only grew the entry, and again with every session whose call came before its receiver's content did. Each call kept on an entry now first leaves one call of each term its calls derive: of the calls of one term, the first by request digest whose inputs the Cloud stores, or the first. The rest are forgotten with their index, the entry is stamped (a new cause, "kept calls joined"), and the change is saved. An entry so holds, beyond one call a term, only the calls of unions since its last kept call. Doing it at the union itself would mean a term key for every call of every entry an input of a joined class names, inside the egraph's union, as classes move. Signed-off-by: Erik Sipsma <[email protected]>
…rm (failing first) Under the Cloud cache's write hold, keeping one more call on an entry takes the term key of every call the entry keeps, to find the calls of the new call's term and those a union has since joined: 4.5 to 5.6 ms on an entry of 10,000 kept calls, measured with this benchmark. The test counts the keys one insert takes there, a new term and an old one, over inputs the Cloud stores and inputs it doesn't, and fails today with 10,002 for each. The benchmark times the same four inserts. Signed-off-by: Erik Sipsma <[email protected]>
Keeping one more call on an entry took the term key of every call the entry keeps, under the Cloud cache's write hold, to find the call of the new call's term and the calls a union has since joined: 4.5 to 5.6 ms on an entry of 10,000 kept calls. The entry now keeps an index of the call it keeps of each term, by term key, and keeping a call takes its own key and one lookup. The key is built in one allocation, where it took two for each input. The index holds while every key in it is the key its call derives now. A key is a call's self digest, which never changes, over each input's class root, or the input digest itself when it has no class. So a key changes only when an input digest's root does, and the index is dropped where that happens, through forgetCallTermsLocked and forgetAllCallTermsLocked, which already drop the entry's grouping: - ensureEqClassForDigestLocked, when a digest gains a class: the only place a running cache adds a digest to egraphDigestToClass. An import adds them too, at startup, before any entry has an index. - mergeEqClassesNoRepairLocked, for each digest of the losing root: the only place a root becomes a child of another. Path compression (findEqClassLocked) points parents at the root they already have, and allocEqClassLocked writes the parent of a class no digest names yet. - compactEqClassesLocked, for every entry: it renumbers every class and drops the classes no longer live, the only place a digest loses its class while entries remain (maybeResetEgraphLocked clears classes only once no entry is left). The next call kept on the entry builds the index again from its calls, leaving one call of each term (joinedTermCallsLocked), as every keep did before. A dropped call leaves the index under its key. Dropping a call scanned every call the entry keeps for each of its inputs, to find whether another still names it: a replacement, or a union that joins many terms, cost that scan per dropped call. The index of call inputs now counts, for each input and entry, the calls naming it. In this package's tests, each keep checks the index against a scan of the entry's calls, and panics if they differ (verifyKeptCallTerms). A test runs random sequences of keeps, new classes, unions, inputs the Cloud comes to store, which make a call replace its term's call, drops and compactions on two caches, one of which drops the index before every keep, as each keep scanned before, and checks after every step that both keep the same calls and that the index agrees with a scan. Signed-off-by: Erik Sipsma <[email protected]>
…asses as they stand when compared A recipient now names terms besides its check's calls (HeldBy.Terms): the terms of its runs' calls that returned another entry, of which the Cloud may keep another run's call. A group of kept calls goes to placement when Calls names one of its calls, as before, or when its term is one the recipient names. A named term is matched by its self digest, which a term's key begins with, and then by taking the named term's key and the kept call's under one hold. StoredSizes and StoredClosure let egraphMu go between entries, and a class merged meanwhile has a new root, so a key taken before the walk would miss its group, and the call the bundle sends would be left out of the price and the closure. Signed-off-by: Erik Sipsma <[email protected]>
…e Cloud can place (failing first) The Cloud keeps every call an engine reports returning one of its entries, one per request digest. Calls of one term are one call to the cache, and a bundle sends one of them, so every further call of a kept term only grows the entry: a large share of kept calls can be more calls of a term their entry already keeps, and one module definition's entry could hold a thousand calls of one term. The first test reports B's call of a term the entry keeps A's call of, with an earlier expiry, and expects A's call alone kept and B's expiry taken. The second makes A's kept call one the Cloud can't place, then reports B's call of the term on a receiver the Cloud stores, and expects B's call to replace A's and to be sent with B's receiver. Both keep two calls today. Signed-off-by: Erik Sipsma <[email protected]>
…ng first) A recipient's named terms (HeldBy.Terms) are indexed by self digest for each walk of a root: StoredSizes and StoredClosure walk each root on its own, as StoredLowerHalf walks the root it splits, and each walk builds the index again. A set's file names its runs' terms, thousands for a heavy check, and prices thousands of roots, so its price reads cost roots times terms: seconds for a file's price reads, against a fraction of a second for a file that names no terms. Its closure and part reads, which build once, were unchanged. HeldBy counts the indexes built for it. The test prices two roots, builds their bundle and lists their closure for one recipient, and expects one index. Today it builds one for each root of each walk. Signed-off-by: Erik Sipsma <[email protected]>
…ts bundles and prices HeldBy builds the index of its named terms by self digest once, on its first use, and every walk for the recipient reads it: StoredSizes and StoredClosure for each root, StoredLowerHalf for the root it splits, and StoredBundle. A set's file, which names thousands of terms and prices thousands of roots, then builds one index, not one for each root. The terms are named as the HeldBy is made and not changed after. Signed-off-by: Erik Sipsma <[email protected]>
An entrypoint keys its module process's exec on the call through the
callDigest argument its call declares. That was the call's recipe digest,
stable across evaluations, sessions, restarts and engines, so the exec
answered every later evaluation of the call, and what it returned named
the results of the engine process that ran it by handle. On another
engine, those numbers named another call's results or none, and a
module's return failed to load ("expected Directory!, got String!",
"missing shared result"), or would load the wrong object of the right
type.
The exec is the function's run, as a container runtime's exec is, and
like it, it now answers only the evaluation that made it: callDigest is
the call's recipe digest with a value of this evaluation's own, as a
function with an explicit TTL already got. What the cache keeps and
shares is the call's result, whose references persistence and import
map to each engine's own. So the function runs whenever dagql evaluates
the call; whether it does is dagql's cache policy alone.
Signed-off-by: Erik Sipsma <[email protected]>
…'t make the row known (failing first) The service's record that lands on a row whose own value the engine keeps is another record of the recipe, maybe another run of the step. The service doesn't hold the engine's record of that row, so an export must carry it in full. Signed-off-by: Erik Sipsma <[email protected]>
A merge of the service's records that lands on a row whose own value the engine keeps doesn't put the service's record there: the service holds another record of the recipe, maybe another run of the step, and not the engine's. Taking the row for known sent it held, and the service then named the run of a value it had never been sent: a result the engine built over its own run was put over another engine's. Only the rows the merge stored the service's records on are known now, so the engine's own row goes in full and the service names its run. Signed-off-by: Erik Sipsma <[email protected]>
…its entry as sendable (failing first) Keeping a call and sending it should judge the call's inputs by one rule, callPlacementLocked. An entry that keeps a call whose input the Cloud knows only by its class, which a bundle sends placed by a stored entry of the class, stamps the entry as kept with a new term a bundle can send. It is stamped as unsendable today, since keeping asks only whether every input is stored under its own recipe. Signed-off-by: Erik Sipsma <[email protected]>
…eads downloaded Every first part lands before any second for the heads downloaded by the time the lane turns to them, not for every head offered at once: a head whose download ends later joins the turns from then. Signed-off-by: Erik Sipsma <[email protected]>
…hat made it (failing first) A Dang entrypoint runs a module function in an exec, the module process, whose stdin carries the call's receiver and arguments and whose output file is the function's return. Both name core objects by handle: entry numbers in the cache of the engine process that ran the exec. That exec is an ordinary withExec, cached by its recipe, persisted and exported, and its recipe was stable for a default function, so it answered any later evaluation of the call: another session's, the same engine's after a restart, and another engine's through the remote cache. Served there, the numbers it returns name results that may be gone, or another call's, of any type. This changes a behavior a test asserted. A default function's exec no longer answers again after a failed attempt: the function runs again, as it does on the container runtime, whose exec is never cached. TestModuleEntrypointCallCachePolicies' "default evaluated again" now expects that, and a new restart subtest of TestDiskPersistenceAcrossRestart expects a call evaluated again after a restart to run the function again rather than be served the process output from before the restart. Signed-off-by: Erik Sipsma <[email protected]>
… rule a bundle sends it by Keeping a call asked only whether every input is stored under its own recipe. Since a sent call's input can be placed by a stored entry of its class, that differs from the rule a bundle sends a call by (callPlacementLocked): a call whose input the Cloud knows only by its class was stamped unsendable though every bundle sends it. Keeping now ranks a call by callPlacementLocked, for a recipient that holds nothing, and keeps the best-placed call of a term, the first of those on a tie. Calls of one term have their inputs in the same classes, and own stored inputs rank first, as they did, so the choice of call changes only where expiry tells them apart: an input's own stored entry places it even when expired, while a class substitute must be unexpired. A call of several inputs whose own entries are missing for some can then place where another call of its term can't, and is kept over it where the two used to tie. Its expired row leaves the call untaught on the recipient, so nothing a recipient sees changes. What changes is the stamp cause, for diagnostics, and that the two rules can no longer drift apart. Signed-off-by: Erik Sipsma <[email protected]>
…hing known A merge of the recipient's records makes known only an entry it stored one on. Knows is exported for the engine's merge to count the kept rows that aren't known at their revisions. Signed-off-by: Erik Sipsma <[email protected]>
…in full A merge that keeps rows the engine holds makes none of them known, so a kept row not known at its revisions goes in full in an export of it: either the engine's own value, or a record the service sent before whose revisions the engine's calls and installs moved since. The merge and restore lines count each (kept_unknown_own, kept_unknown_sent), from a reply that now says whether a target holds the engine's own value (MergedValue.Own), so a run reads what the rule adds to its exports. Signed-off-by: Erik Sipsma <[email protected]>
… goes untaught Class placement's test of a held row checked that a bundle whose call is placed by the recipient's own copy of the call's input names that row, carries no copy of the record, makes it no root, and still merges into a recipient that no longer holds the input. Keeping one call of a term rewrote that test for the call it keeps, whose own stored input now places it, and the held row went with it. This keeps the check, for a recipient that holds the kept call's own receiver. Signed-off-by: Erik Sipsma <[email protected]>
…arge class Keeping a call now ranks it by the rule a bundle sends it by, which places an input with no stored entry of its own through its class's stored entries and scans them. A call of a kept term over a client-specific receiver, equal in content to many sessions' receivers, is such a call. The keep benchmark's inputs had classes of one or two, so it never took that scan. These cases keep such a call on an entry whose class has 100 or 1,000 stored entries, with the term's kept call placed by its own stored input or by the class. Signed-off-by: Erik Sipsma <[email protected]>
…r than the kept call Keeping a call of a term the entry keeps a call of ranked both calls by the rule a bundle sends them by, which scans an input's class for a stored entry when the input has none of its own. A call over a client-specific receiver, one of many sessions' receivers of one content, scanned that class under the cache's write hold, only to be refused. No call places better than one whose inputs are its own stored entries, so the kept call is ranked first, and the new call only when the kept call isn't one. Signed-off-by: Erik Sipsma <[email protected]>
A merge that refuses an export for its stale held rows now says, for each row, which check found it stale (MergeReply.StaleWhy): - "no entry": the row's recipe has no current entry; - "no value" or "expired": the entry has no value, or has expired where the row hasn't; - for a part the export puts on the row: the part missing from the entry's record, or the check that refused it. A state that differs now names both: the row's, then the record's. The reasons come from the checks the merge already makes, which say why in place of yes or no; nothing else they decide changes. They are for the Cloud's log, and are not sent to the engine. Signed-off-by: Erik Sipsma <[email protected]>
…through the cache
The test's compaction step set the entry's output classes in the cache's
table directly. Since a compaction decides from the uses the cache keeps
of each class ("dagql: a compaction check reads the live classes the
cache keeps"), counted as entries' output classes are added and removed,
those classes counted no use: the cache saw no live class, never
compacted, and no sequence dropped an entry's term index by a
compaction, which the test requires one to. The package's close-time
check also found those caches' kept uses differing from a walk. The step
now removes and adds the entry's output classes through the cache's own
functions.
Signed-off-by: Erik Sipsma <[email protected]>
The test made A's call one the Cloud can't place by unindexing its receiver's recipe. Since a sent call's input is placed by a stored entry of its class (class placement), the receiver, still a stored member of its class, places A's call by the class, and the test's first check failed. The receiver now leaves its class too, so no stored entry stands for it, and the rest of the test is unchanged: B's call, whose receiver the Cloud stores, replaces A's. Signed-off-by: Erik Sipsma <[email protected]>
…are known A bundle can carry two records of one recipe that land on one entry: an expired record the merge keeps and the current one it stores there. The stored one makes the entry known, so the kept one is no row an export carries in full, and isn't counted as one. Signed-off-by: Erik Sipsma <[email protected]>
… kept call of it is one its check made (failing first) A bundle for a recipient sends the terms its check's runs made, found by the request digests of their calls (HeldBy.Calls). Once the Cloud keeps one call of each term on an entry, the call it keeps may be another run's, and then none of the recipient's request digests names the term. HeldBy gains Terms, each a self digest and the inputs the engine reported, which the bundle doesn't read yet. The first test names such a term and expects its call sent with the receiver the Cloud stores, priced and listed as built, and a fresh engine to hit it; naming nothing sends nothing. The second names a term while a walk that lets the cache's lock go merges the call's input class at every yield, and expects the price and the closure to match the build: a key taken before the walk names the class's old root. Signed-off-by: Erik Sipsma <[email protected]>
… class is stored A call often comes before its receiver is exported. An entry keeps one call of a term, and may keep one that no bundle can place when it came, with the call that came after equally unplaceable. Its receiver stored later, under its own recipe or another's of its class, places the kept call by the class (class placement), so a set whose check made the other call still gets the term: a receiver stored after its call is covered by class placement, with no change to how calls are kept. The test keeps A's call with A's receiver stored under no recipe and in no class, has B's call come while the Cloud knows B's receiver only by its content, in A's class, and then stores B's receiver from cache-b's export. A bundle for a recipient naming B's call and its term, as a set does, sends A's call with B's receiver standing for A's, and a fresh engine hits it. Signed-off-by: Erik Sipsma <[email protected]>
Each write kept its own record of the holdings it changed, so that two writes running beside each other wouldn't mix their marks. They no longer run beside each other (the step that would have run them so isn't built), so the record protects nothing. This takes back, as one change, the four commits that added it: "dagql: test that a write's change names only its own holdings", "dagql: each write keeps its own record of the holdings it changed", "dagql: a write's holding marks skip a repeat and start with room" and "dagql: a write's holding marks grow as they come". A write's holding marks go to the cache's one buffer again, with its entry and class marks, and are handed back by the write at its end, as before. The compaction check, which came after the record, notes the classes compacted in the same buffer, only when it compacts, and the two tests of a call whose input has no stored record drop the receiver's value without a record of their own. The call of a term an entry keeps (keepTermCallLocked), which also came after, notes the kept call in the same buffer. Nothing the cache decides changes. Cloud rows that mark holdings were 3 to 4% faster with the record; this gives that back. Lock order this leaves: unchanged, egraphMu alone. Signed-off-by: Erik Sipsma <[email protected]>
…copy (failing first) The Cloud checks each part an engine's export puts on a held row against its own copy of the row, the current entry of the row's recipe. A part the row says is pending, where the copy has it completed, is judged stale today, and the whole export with it. The row's recipe is the copy's, and a part the copy has completed holds everything the row says is still to come of it: the merge would keep the copy's value, and it has the part. An engine's exports could be refused again and again so: a container a sync completes only the metadata of holds its other parts pending, where another engine that ran the same call and read them exported them completed. The test's reference, which decodes the copy, now says so, and the case of a complete part held as pending expects it to hold. A complete part's upload, an absent or metadata part held as pending, and a part the copy lacks still don't hold. A test of the Cloud's part facts used that check to tell a record's pending part from a completed one, which it no longer can: it reads the record's part state itself. "several, one not" fails on an absent part held as pending in place of a complete one. Signed-off-by: Erik Sipsma <[email protected]>
…pleted The Cloud checked each part an export puts on a held row against its own copy of the row as a bundle checks an output against its own record: the states must match, but for a completed output against a pending record. That rule is a bundle's: a part its record captured pending may have completed by the time it is described. A held row's part is checked against another record of the row's recipe, which the merge keeps, and a copy that has the part completed holds everything the row says is still to come of it. Judging that stale refused the whole export, and the engine, which then sent the row in full and had it merged, held it again on its next export, and was refused again. checkHeldPart is that rule: a pending part the row puts nothing on to store is held by a completed copy; every other part is checked as before. An upload onto a completed part, an absent or metadata part against a pending one, and a part the copy lacks still don't hold. Signed-off-by: Erik Sipsma <[email protected]>
A class's extra digests were a Go map of their own, a header and a group of eight slots, for what is nearly always one content digest; a class taught a frame without extra digests got an empty one. They are now a short list a class holds only when it has one: a lookup in it is a linear search of a few items, and a join appends the absorbed class's digests it lacks. Signed-off-by: Erik Sipsma <[email protected]>
Members returns one key's members with one lookup, for a reader that asks several questions of them; Move adds one key's members to another's, as a join of two classes does, and moves the set itself when the other key has none; Clone copies a key's members into a set of their own. Signed-off-by: Erik Sipsma <[email protected]>
…member in place An entry's classes, a class's entries, a class's input and output terms, and the terms of a term digest were each a set of their own, nearly always of one member. They are now idSetIndexes: a key with one member holds it in its map slot, and a join moves a class's members to the class that survives. A class's digests keep their sets, as most classes have several. Signed-off-by: Erik Sipsma <[email protected]>
…sk a key once A join rewrote each moved entry's classes with a size, a membership, a removal and an insertion, four lookups where its set was found once; it now renames the absorbed class to the surviving one (Rename) with one, and learns from it whether the entry already named the survivor. The union, the repair of a class's terms, the restore of the postings and the checks of class uses read a key's members once (Members, Entries), and a class's entries are cloned from their list or map directly. A merge of a term digest's outputs reads the digest's terms again after its union, whose repairs may move terms between digests. The tests check that a reset leaves each index with no map at all, that Rename answers as a set would, and that a clone is a set of its own. Signed-off-by: Erik Sipsma <[email protected]>
The members view returned one function or another from All and Items, so the function it returned escaped and was allocated on every walk, as a lookup's walk of a term digest's terms. Each now returns one function that walks either form, as idSet's own iterators do, which the compiler keeps off the heap. Signed-off-by: Erik Sipsma <[email protected]>
…less it brings a part (failing first) A record's bundle reads its class only to borrow a part a class mate stores. An entry that stores no part joining the record's class gives the record nothing new to borrow, so the record and its other class mates stay current; the joining entry can borrow the class's part now, so its own stamp moves. Today every entry of the joined class is stamped as soon as either side stores a part. BenchmarkClassJoin times a new entry joining a class of 1,000 and of 10,000 entries that hold no part. Signed-off-by: Erik Sipsma <[email protected]>
A join of two classes marked what it changed by asking every entry of both sides whether it holds a part, to decide whose entries to name for readers, and at hand-back scanned the joined class again for a stored part, stamping every entry of the class when it found one. A new entry joining a class of thousands paid for the thousands, under the write lock, every time. What a join changes for an entry is what the other side brings: its holders' part answers and its stored parts to borrow. So only the smaller side is walked. Each of its entries is named for readers and takes a class mark of its own, which stamps it and, for an entry that stores a part, widens to the joined class when the marks are applied, as any lender's mark does. The larger side's entries are named only when the smaller side holds a part. A join now costs its smaller side, as a union by size does, with nothing new to keep up. Only a cache with a reader of its changes marks (changes non-nil): an engine's own cache marks nothing, and nothing changes for it. The larger side is no longer stamped when only it stores a part: its bundles borrow nothing new. The smaller side is named and stamped even when the larger side holds and stores nothing; a reader finds those answers unchanged, and a new entry's own marks name it already. Signed-off-by: Erik Sipsma <[email protected]>
… joins By the exact rule a join names a side's entries when the other side holds a part, and stamps them when the other side stores one. Over random classes, some entries in two classes, and random writes between hand-backs (joins, parts stored and dropped, entries leaving, holds ending), every entry the exact rule names at a join is named in the change handed back, and every entry it stamps has a later stamp. Signed-off-by: Erik Sipsma <[email protected]>
BenchmarkClassJoin reports, beside a join's time, the entries its change names for readers, and BenchmarkClassJoinOfTwoClasses times a join of two classes of 100 and of 1,000 entries that hold no part, as a kept record's identity can join two classes the cache had: the case where a join names entries of a side whose answers didn't change. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
…g first) An entry of a join's smaller side that stores a part, and is also in a third class, gives that third class's other entries nothing new to borrow, but its mark widens to every class it is in, so they are stamped as changed and the whole third class is walked under the write lock. The random joins' test now checks each join's names against what that join named, and the stamps as each hold of a write ends, not only once the marks are handed back. Signed-off-by: Erik Sipsma <[email protected]>
A join's smaller side was stamped through class marks of its entries, and a mark of an entry that stores a part widens to every class the entry is in. An entry in a third class so stamped that class's other entries too, though they gained nothing to borrow, and walked it under the write lock. The smaller side's entries are now stamped as the join walks them. When one of them stores a part, the join marks the class it joined, and every entry of that class is stamped when the marks are applied, once however many joins marked it, as the class is then. No other class is walked. Signed-off-by: Erik Sipsma <[email protected]>
…ge one A new holding with the class's content digest joined no class: its entry is placed in the class as it is made. The benchmark now makes the entry first, alone in its class, and times the holding of another engine that gives it the content digest, so that its class joins the large one. Signed-off-by: Erik Sipsma <[email protected]>
… hold's stamps apart Signed-off-by: Erik Sipsma <[email protected]>
…lection that frees its number (failing first) A join that brings a stored part marks the class it joined by its number, stamped when the marks are applied. A later join of the same write can join that class away, and a collection, which a value merge runs before it hands its marks back, then frees the number: the stamp is lost, or goes to a new class that took the number. The join tests' cache keeps the classes' uses and notes the classes a union ends, as the cache does, so that the collector frees them in the random test too, and checks the classes after each collection. Signed-off-by: Erik Sipsma <[email protected]>
…t frees classes The collector frees the classes that ended, a class a union joined away among them, and gives their numbers to new classes. A join that brought a stored part keeps its class's number until the marks are applied, and a value merge collects before it hands its marks back. Before it frees anything, the collector now moves each pending join's class to its root, while the parents still lead there, and drops one whose root nothing uses, which has no entry to stamp. The classes' check after a collection checks the pending joins too, and the e-graph's reset clears them. Signed-off-by: Erik Sipsma <[email protected]>
…g (failing first) A join names the smaller side's entries for readers and stamps them whatever the larger side holds. When neither side holds a part, as two lone entries' classes joined by rows that teach them one content, no entry's answers change and nothing it borrows does, but the smaller side's entry is named and stamped, and a reader is told to read it again for nothing. Signed-off-by: Erik Sipsma <[email protected]>
… smaller side has The smaller side's entries need naming only when the larger side holds a part, and stamping only when it stores one. The join now reads that from as many of the larger side's entries as the smaller side has, or fewer once one stores a part: all of them when the sides are as large, as two lone entries are, so such a join names and stamps only what changed. Where that read doesn't decide, the smaller side is named and stamped as before. Deciding what to mark reads at most twice the smaller side; marking the larger side, when the smaller side holds or stores a part, costs what it marks, as before. Signed-off-by: Erik Sipsma <[email protected]>
…r calls A merge over the message limit is split: what its root's bundle carries below the root goes ahead, as roots of their own, and the root follows once the recipient holds them. Each of those roots was bundled as if it were a new root, with every call kept on its entries and those calls' inputs added as roots of their own. Where calls tie entries together, as when an object held in a field keeps a call from every object that holds it, a bundle of almost any one entry carries all of them: each part was over the limit again, and was split in turn, root after root, for nearly the same entries each time. HeldBy.Parts names the roots a bundle carries as parts of another root's merge. Their walks place a call only on inputs the bundle carries or the recipient holds, and add no input. HeldBy.Through names the entries of the parts that landed: the root's merge walks through them, as held rows, so that the calls kept on them and below them go, placed on what the merge carries or the recipient holds. An entry below a part's top that a call names goes as a held row the call alone names, outside the roots' closure; the bundle check accepts one as a call's value, and the recipient teaches the call onto its own entry of the row's recipe, as it already did for an input. So the parts and the root's merge leave the recipient with the records and the calls one merge of the root gives it. StoredLowerHalf becomes StoredLowerPart. It no longer sends the first half of what is below the root: it leaves the root's merge a tail of the bundle, grown from the bundle's end while it fits within the limit beside the root's records, the held rows those records name, the bundle's calls and the held rows the calls name, and sends the rest ahead, so that a root is split once. It returns every entry of the part, for HeldBy.Through, and the encoded size of the calls and of the held rows they name. StoredSizesAlone prices a part as StoredSizes does, and refuses HeldBy.Through, as StoredClosure does. Signed-off-by: Erik Sipsma <[email protected]>
… and stays within the limit (failing first) A call kept on an entry the recipient held before the split, below the lower part's top, goes with neither the part nor the root's merge: the part can't bring the call's input, and the root's merge stops at the part's top. And the root's merge can price over the limit when the part sends ahead the first record that lists a chain of layers a record the merge keeps lists too. Signed-off-by: Erik Sipsma <[email protected]>
…ach output once The root's merge after a split walks through the lower part for the calls kept on it. It now reaches too the entries below the part that the recipient held before the split, and sends the calls kept on them, without walking below them, as the root's one merge would have reached them as held rows. Each goes as a held row once a record or a call names it. StoredLowerPart counts the outputs of what the root's merge keeps as that merge lists them, each layer and blob address once, not as the bundle's first record to name them did. A held row the root's merge needs, for an entry of the part that a call or a kept record names, is counted once, and not at all for an entry the merge keeps in full. Signed-off-by: Erik Sipsma <[email protected]>
…lob is in two packs (failing first) Which of a blob's addresses the root's merge names first depends on the order it lists its outputs in. The cut counted them from the tail's end, and names a later output's pack first: with the first output in one pack and the others in another, the root's merge is priced over the limit. The recipient's hits are checked against the entry the call returns, with a miss that runs nothing the engine keeps. Signed-off-by: Erik Sipsma <[email protected]>
…ts outputs StoredLowerPart grows the tail the root's merge keeps from the bundle's end, counting each record's outputs as it comes. Which of a blob's addresses the merge names depends on the order it lists them in, so the cut is then checked as that merge counts it, in the bundle's order, and moved down to the first cut that fits. Signed-off-by: Erik Sipsma <[email protected]>
…tions of their own StoredLowerPart grew past the linter's bound on a function's branches. Its walk (storedCutWalk), the tail's growth from the bundle's end (grow) and the check in the bundle's order (settle, fits) are each a function of the cut they read, storedCut. Nothing they compute changes. Signed-off-by: Erik Sipsma <[email protected]>
…(failing first) A chain import downloads the blobs of the layers after the one it imports ahead, each under a lease of its own. A download stores its blob a moment before it ends and releases that lease. An import that gets to the layer in that moment finds the blob stored and uses it, then lets go of the download without waiting for it: it returns while the download's lease still holds the blob, and a garbage collection in that moment keeps the blob. The test holds such a download for a moment after its blob is stored, and requires the released import to leave no lease behind and its blobs to be collected. It fails: the download's lease is still there. The test store gains AfterCommit, which runs after each content write commits, on the writer's goroutine. Signed-off-by: Erik Sipsma <[email protected]>
An import let go of the download it held for a layer once the layer was imported, and waited for the download to stop only when the import failed. A download whose blob the import found already stored, because the download had stored it but not yet ended, was abandoned without a wait: the import returned while the download's lease still held the blob, and a garbage collection in that moment kept it until the next. An import now lets go of every download it holds as a failed one does: the last hold of a download that has not ended cancels it and waits for it to stop and release its lease. A successful import waits only for a download nobody else holds that has not ended: one whose blob it found stored in that moment, or one that another import's layer made unneeded. Signed-off-by: Erik Sipsma <[email protected]>
…it (failing first) A layer exported as a listing goes from its differ to its split through a pipe: the differ walks the layer and writes its tar, and the split reads it, writing each larger file's content blob as it reaches it. Through a pipe each waits for the other. While the split waits for room to hold a file, or writes one too large to hold, the differ can't read its next file, though reading the layer's files one after another is most of a large layer's build. This test holds the content store's writers closed while a layer's tar is written through its listing compressor, and expects the differ's write of the whole tar to return while they stay closed, with a listing that rebuilds the tar once they open. Today the write waits until the store lets the split go on. Signed-off-by: Erik Sipsma <[email protected]>
…split A layer exported as a listing went from its differ to its split through an io.Pipe, so each waited for the other. The differ walks the layer and reads its files one after another. The split stops reading the tar while it writes a file too large to hold, or while it waits for room to hold one. For a layer of many files, the differ's walk is most of the build, and it stood still whenever the split did. Now a buffer of up to 16 MiB carries the tar between them. A write returns once its bytes are held, and waits only for room, so the differ reads ahead while the split writes. The buffer holds its bytes in the 1 MiB pieces the layer digester already pools. They are taken as writes need them and given back as they are read, so a small layer's tar takes one piece. The split ends it as it ended the pipe: its error, or io.ErrClosedPipe, ends any write still waiting. On a layer of many small files, built for export with a build per core, this took about a fifth off its build's time. The blobs are the same: the listing and every content blob have the same digests. Signed-off-by: Erik Sipsma <[email protected]>
The buffer between a layer's differ and its split counted only the bytes not yet read against its 16 MiB. A piece read in part stays held until all of it is read, so with its bytes it could hold one piece more than that. Now it counts pieces: a write that needs a piece past the buffer's size waits for a read to give one back. What a layer holds there is never more than 16 MiB, read or not. Its test now waits for the writer to block, with testing/synctest, rather than for a timer, and it holds a piece read in part while the writer needs another. Signed-off-by: Erik Sipsma <[email protected]>
…ns as its timer fires TestListingSplitDoesNotHoldTheDiffer gives the differ's write 30 s to return while the content store's writers stay closed. On a runner stalled long enough for the write's return and the timer to be ready together, the select could take the timer and fail a write that had returned. Now the timer's case looks for the write's return first, and fails only when the write is still waiting. Signed-off-by: Erik Sipsma <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
DCO reports no verdict: its app reads only 250 of this pull request's commits. Every commit is signed off.
This is the engine side of the remote cache: what an engine needs to share its cache with other engines through a remote cache service. It also carries the changes to the local cache that work needed. Most of what it changes applies to every engine, with or without a remote cache, so that part comes first.
What changes for every engine
These apply whether or not a remote cache is configured.
directory,file,glob,search,findUp,findRoots,git) are shared across clients and sessions too. Modules and workspaces from a local path stay per client./is keyed by its root too, though a copy of a directory is still keyed by the files it copies. A module object's key includes its type. A failed check's run is bound to its session. A Dang function runs again after a failed attempt. Details are below..envstays out of the cache. A module source no longer keeps every line of the caller's nearest.envas hidden expansion context, only the lines its defaults name. So a caller's unrelated lines, such as another app's credentials, no longer reach the engine's saved cache or anything the cache shares with other engines. The caller's.envis also read directly instead of being imported into the client's file-sync mirror, so the file no longer stays on the engine's disk. Two behaviors change. A default that builds a variable name at expansion time from parts of values or from the host, through${!NAME}or arithmetic, now reads only the kept lines, and otherwise the host's variable. And a caller's.envover 3,984,588 bytes now fails the module load, with an error that names the file and the limit.--network-cidroverlaps a network it is attached to moves to the next free range and logs a warning (engine: a nested engine on its parent's address range can resolve names again #15099).reservedSpaceandminFreeSpacedo.Directory.__gitSparseCovers, and one argument,sourceDateEpoch, on the hidden_engineImageBundle.The remote cache
None of this runs unless an engine has a remote cache URL and an engine token.
An engine with a remote cache reports what its cache holds to the service through telemetry. At connect, it restores the records the service publishes for its check. Each check's records come as a chain of set file segments, each named by the digest of its bytes, and the file's digest is the chain's (
protocol.SetFileChain). The engine checks that digest, fetches every segment at once, checks each against its own digest, and merges them in order, a record that a later segment carries again answering for its last copy. Each segment says what it is in its file (SetFileRole): a head's first part, the lead a later build adds to that part, the rest of a head, or the set segment. The restore's head lane merges a head's lead in the same turn as its first part's last part, so what a rerun asks for first lands in the head's first turns even when a head is added to rather than rebuilt, and the restore report, the stop event and the answer say when a head's first part landed. As it runs, it looks up calls that another engine may have made, and it exports its own results' records and layers. Layers go as a listing plus content blobs for files of 256 KiB or more, so files are fetched once wherever they appear. A layer exported as a listing goes from its differ to its split through a buffer of up to 16 MiB instead of a pipe, so the differ keeps reading the layer's files while the split writes their content blobs, with the same bytes. A record fetched from another engine is prepared at its first use, not when it arrives. Content fetches log the longest any request went without progress (idle_max), and a failed install logs the layer and step that failed, without the presigned address. A chain import no longer returns while a download it started ahead, whose blob it already used, still holds that blob under its own lease, so a garbage collection right after the import frees what it should. The lookups for calls an engine missed are answered in runs of reads under one hold of the cache.The engine's protocol with the service (
engine/remotecache/protocol) is at bundle version 13, against 7 on main. Engines and the service move together, with no compatibility path. The protocol compresses its own messages, with the WebSocket's compression off: an envelope over 512 bytes of JSON is encoded straight into one zstd frame, which declares its JSON's length, before a write takes the connection. Before, the library compressed each message under the connection's write lock, and every other message on it waited. The protocol package can also read a restored file's complete parts as their indexes in the file's table, four bytes a part (UnpackPartIndexes), for a reader that keeps them. Nothing on the wire changes for it.dagqlalso gains a blob-backed mode of its own cache (WithBlobStore, "the Cloud" in its code), which the remote cache service builds on. That is why much of the change is indagql. In that mode, a merge decodes each record's payload once and relocates it once, straight to the numbers it is stored at; a set file's parts and stored values are encoded in place, and a stored bundle lists each layer once; and its saved store keeps its change stamps across a restart.Cache.StoredSizesAloneanswers, for up to 64 roots, whatStoredSizesanswers for each root alone, from one walk of their closures instead of one walk each, and adds up each root's size on a private copy outside the cache's lock, so every answer equalsStoredSizes. On a bench of 2,507 roots in 40 batches over a large store, that took 6.9 s against 95.2 s one by one.Cache.StoredSizesUntilmeasures root by root asStoredSizesdoes, and stops once the caller's check says the sizes so far decide what it keeps, so a caller keeping a prefix that fits a bound measures nothing past the first root over it.HeldBy.Alsonow gives, with each entry it names, the cache position the recipient holds it as of, and the cache counts the entry held only while no write since that position changed what a stored bundle carries of it (the ruleChangedSinceapplies), judged under the hold of the build or price that asks; a bundle names the entries it carried in full for that reason (StoredBundleResult.Changed). Every hold ofdagql's graph lock for reading can now be timed by the kind of work it reads for, as holds for writing already are (ObserveGraphReadHolds, andwcprof.ReadLockAsandRLockAs). With no observer, a hold costs about 4 ns more thanRLockandRUnlock, and a cached call hit is unchanged. A stored bundle, price or closure for a recipient that names terms matches each kept call's term by key: the recipient's terms are keyed once in each hold of the cache's read lock, not again at every comparison, so a walk over entries that keep many calls of one self digest no longer holds the lock for seconds, and what is sent is unchanged. A stored bundle also reads each class once for the donors of the parts its entries borrow, not once for every entry that borrows, so a bundle carrying many entries of one large class no longer holds the read lock for seconds; the donor chosen, and so the part sent, is unchanged. A frame a merge installs keeps the recipe digest the merge landed its record by, so the blob-backed cache's body worker no longer reads the graph lock once per input while it compresses newly stored records, and those records no longer wait decoded behind busy writers. A blob-backed cache also holds what it stores of each entry in less memory: stored entries share one light envelope for each distinct content, a stored body holds its envelope and frame in one allocation and its references as varint differences, an entry's stored parts are a sorted list, and held parts share their platform, held layers their media type and description. Nothing a store saves or an engine is sent changes. Adagqlrecord of another cache's copy of an entry (a holding) takes 144 bytes in place of 208: the fields most holdings leave empty sit behind one pointer, and its yes-or-no facts share a byte. Every answer stays the same.TransferredValue.EncodedSizecounts a value a blob-backed cache holds compressed from the JSON lengths kept beside its envelope and call frame, without decompressing or encoding them, and the count equalsjson.Marshal's length byte for byte. A blob-backed cache reports, with each write's change, the numbers of an engine cache that no holding has and that the write left named by no holding (RemoteChange.UnheldCandidates), and how many holdings name a number (RemoteDependents), so a caller that keeps such entries outside the holdings needn't read every holding again to find what lost an owner. In a blob-backed cache, a merge's preparation compresses each record it will install into the body the store keeps, from the JSON it already encodes to measure the record, and the commit installs that body: the body worker no longer normalizes and encodes the record again, and read-only walks of a record's payloads no longer copy its envelope. What is stored is byte for byte the same. A stored body of at most one zstd block (128 KiB of JSON) compresses on an encoder that runs as many compressions at once as there are cores; a larger one still compresses one at a time.KeepNeededBundleRowsexports the rule an export's capture uses to leave out the known rows nothing in a bundle stands on, for other producers of bundles. A blob-backed cache's class join decides what it marks for readers and stored bundles by reading at most twice its smaller side instead of every entry of both classes, and stamps only the class that gained a part to borrow, so joining a lone entry to a class of thousands no longer walks the class under the write lock; only a cache with a reader of its changes marks, so no engine's own cache changes. When the remote cache splits a merge over the message limit, the parts it sends ahead carry their records and only the calls they can place, and the root's own merge walks through them and sends the rest, so a root is split once instead of each part being split again, and the engine still ends with every record and call. Measuring tests for a saved blob-backed cache (dagql/cache_saved_store_test.go: the restored heap by kind, the records, and the restore, bundle and save times) skip unless given-savedstore, beside two benchmarks of work under the cache's write hold. What goes on the wire is unchanged. A blob-backed cache's changes carry the facts of each holding they name, so their reader needn't read the holdings back. An engine that restored the service's records holds each layer of the parts it is offered once, where each output kept its own copy of its chain's layer list: in a test of 200 parts on a base of 40 layers, each part's reference to a base layer takes 10 bytes of live heap, against 219. The service applies an engine's merged reply against a compact record of the bundle it sent (ValueBundle.Sent), not the whole bundle. A merge that is prepared and waiting for its commit no longer keeps the private cache its preparation used, its early decision, or a record for each held row. On a bench of recorded export replies, a prepared merge held 56% less heap (1.35 against 3.06 heap bytes for each encoded byte), with the same CPU to prepare it.An export that selects parts no longer carries the held rows that nothing in it stands on but that lie on the way from a root down to something it does carry: a needed held row links straight past them, keeping each root's path to every row it reached. The format and the receiving merge are unchanged. On 1,384 recorded export replies, the rows fall 77% and the links 87%, and the CPU to prepare them falls about 39%. One thing changes on the receiving side: an expired copy of a row such a link goes past no longer refuses the export as stale; it stays expired until a later export carries the row.
Early snapshot sharing is removed. On main it is a background pass on remote-cache engines that gives an imported record the content of an equal local result before any call asks for it. The cache already takes a ready local equivalent when a call asks, on every engine. This deletes 1,674 lines of code and 2,893 of tests that are on main (
dagql/cache_snapshot_sharing.go,engine/server/snapshot_sharing.go,engine/snapshot_share.goandcore/persisted_decode_defaults.go, with their tests), and the start-up hook that built the core schema early on remote-cache engines. A decoded module's core API view after a restart, whichcore/persisted_decode_defaults.gopinned, is now pinned inpersistedModuleDefaultDeps(core/module.go). Main's test of it,module reloaded after restart keeps its core API viewincore/integration/engine_persistence_test.go, still guards it.Measured
On dagger's own CI checks, each run on a fresh engine with the remote cache, against this branch as it stood before its rebase onto main. Both ran on the night of 24 to 25 Nov, from the same place, on the same commits: one run each, first readings. Two measures, each summed over the checks:
These figures are from this branch as it stood on 24 Nov, before its rebase onto
44fb8c1907and before the changes in The remote cache to merges, encoding and saves.How to review this
942 commits on main at
ba6b630b0b. Each commit is one change with its own message, and many come in pairs: a failing test, then its fix. A suggested order:coreandcore/schema(about 100 commits): module and workspace caching across sessions, the results that stop being shared, and the hidden field. This is where the behaviour every user sees changes.dagql, the local cache (the commits not about the remote or stored cache): result identity, the e-graph, pruning and persistence, and the saved cache's format.internal/buildkit/util/compression,engine/snapshots,engine/cachevolumedir, the network pool: zstd frames, layer listings and content blobs, faster stops..dagger/modules/engine-dev: the image build.engine/remotecache(the client and its protocol),engine/server'sremote_cache_*files (the adapter between the engine and the client), and indagqlthe stored cache and transfers (cache_remote_*,cache_stored_*,cache_value_*,cache_transfer_*). About 570 of the commits touchdagql, most of them here.Details
Results that stop being shared
/is keyed by its root and its files, so two directories holding the same files at different roots are two results, andDirectory.name,diffand a mount'sdirectoryanswer with their own root; a directory rooted at/keeps the key main gives it. A copy (withDirectory, except withgitignore) is keyed by the files it copied, so the same files copied from differently rooted directories are still one result; a mount is keyed by its root.ModuleSourcefields that read the caller's.envor resolve versions live are keyed per client:withName,withSdk,withUpdateDependencies,withUpdateToolchains,withUpdateBlueprint,withClientandwithUpdatedClients.Caching across sessions
core/workspace_identity.go), so a workspace made bywithWorkdiror an edit shares reads with any other workspace of that same identity, however it was made.Workspace.artifactsselection keeps only the collection roots of the modules it holds artifacts of, so a selection's stored value and a collection check's identity no longer depend on modules it doesn't select. Since artifact: simpler columns and shorter links for workspace artifacts #15177, discovery with an include loads every module's schema to name the columns, and the selection kept all of their collection roots too. The columns are still named from every module.Directory.digestis kept on disk past its session.zstd
Stopping and other speed
Telemetry
dagger.io/cache.caller) and, on hits, when the value was loaded and served.dagger.io/cache.persisted), besidedagger.io/cache.retained, which stays the entry's retention from any source. A reader learning what a session's run kept no longer takes an edge a restored record or another call gave the entry for the run's own.engine.sharebecomesengine.parts(telemetryattrs.EnginePartsEvent). With early snapshot sharing gone, it carries only the complete parts an entry's spans left out.dagger.io/lazy.anchor, instead of repeating every link. The TUI follows the chain back to the call (dagui: read a call the same when later lazy evaluations link the first one #14874).Tests that change
TestModuleEntrypointCallCachePolicies: a default-policy function runs again after a failed attempt.TestDaggerCMD/TestAgentWorkspaceChangescompares the agent's workspace by what it holds, its commit at HEAD and its edit, not by its ID. Loading by ID serves the earliest equal result, and equal workspaces now share one.TestCachePersistence/TestDiskPersistenceAcrossRestart/imported_host_directory_projection_keeps_its_digest_after_restart: two of its assertions expected an exec over mounts of differently rooted directories with the same files to be served from cache. Now they expect it to run again. Its other two assertions don't change.test-split:test-ebpf, andengine-dev:release-dry-runalso checks that only the engine and the CLI carry the commit, and that the image's entries made again after a prune ship the same blobs.Pull requests this carries
This includes the commits of #15162 (bind session-bound results to the session that made them) and #15099 (a nested engine on its parent's address range can resolve names again). Both are closed in favor of this one.