Skip to content

fix caching of fields that return lists - #10410

Merged
sipsma merged 4 commits into
dagger:mainfrom
sipsma:adjust-enum-loading
May 16, 2025
Merged

sipsma merged 4 commits into
dagger:mainfrom
sipsma:adjust-enum-loading

Conversation

@sipsma

@sipsma sipsma commented May 14, 2025 •

Copy link
Copy Markdown
Contributor

Spinning out a fix made while working on the dagql persistent cache. Main motivation is that I'm getting an aneurysm trying to think about the correctness of this fix in combination w/ all the other changes I'm making there, so splitting out here will help verify it independently with fewer health risks.

If correct, this is likely a performance improvement in the immediate term anyways since it would mean previously we were re-calling fields that returned lists for each element in them when loading IDs. And for the persistent dagql cache work this is strictly necessary for basic correctness.


IDs with an nth element selected were overwriting the "leaf" selection rather than appending a new selection of the nth element.

This meant that when we loaded elements from a list in an ID the ID digest was different for every element of the list with no stable digest for the list as a whole.

So the end result was that we'd repeatedly call the field that returns the list for every element in the list. This is obviously not ideal for performance, though it would have only impacted dagql caching so far.

  • Can see this in the newly added unit test; it failed before the fix here because the field that returned a list was getting re-called every time any element from it was loaded

The fix here changes IDs to append a new selection for the nth element on top of the original selection that returns the list. It then handles this carefully in ID loading such that the list is first loaded once with a stable id digest (and thus only called once thanks to dagql caching), after which elements are selected from it.


TODO:

@sipsma
sipsma requested a review from vito May 14, 2025 23:01
@sipsma sipsma changed the title retain ID digest of both enumerable+elements fix caching of fields that return lists May 15, 2025
sipsma added 3 commits May 14, 2025 22:45
IDs with an nth element selected were overwriting the "leaf" selection
rather than appending a new selection of the nth element.

This meant that when we loaded elements from a list in an ID the ID
digest was different for every element of the list with no stable digest
for the list as a whole.

So I *think* the end result was that we'd repeatedly call the field that
returns the list *for every element in the list*. This is obviously not
ideal for performance, though it would have only impacted dagql caching
so far.

The fix here changes IDs to append a new selection for the nth element
on top of the original selection that returns the list. It then handles
this carefully in ID loading such that the list is first loaded once
with a stable id digest (and thus only called once thanks to dagql
caching), after which elements are selected from it.

Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the adjust-enum-loading branch from a6d4eb7 to 64e1e43 Compare May 15, 2025 05:45
@sipsma
sipsma requested a review from jedevc May 15, 2025 14:11
@sipsma
sipsma force-pushed the adjust-enum-loading branch from 71d03ef to 8a561ea Compare May 15, 2025 20:21
@jedevc jedevc added this to the v0.18.9 milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants