Repository navigation
Conversation
These IDs can get comically large and it makes it difficult to display them anywhere. Now we'll use the same hashing scheme used for service hostnames to create much shorter IDs that are mapped to full objects in-memory. Signed-off-by: Alex Suraci <[email protected]>
This is mostly a "when in rome" decision, but I'm not 100% sold on it. It made sense to use xxh3 and base32 for container hostnames owing to size restrictions but it doesn't make as much sense everywhere else. Signed-off-by: Alex Suraci <[email protected]>
|
I tried this a long time ago but backed out because it breaks the caching of extension outputs. Basically, if an extensions returns a Container/Directory/File, it does so by writing the id to a mount for the result. That way you can obtain the result of the extension from the cache without having to necessarily re-run it. I think we can probably find other ways of dealing with that such as giving extensions some internal api for mapping hashed id->full id to let them still persist full id. So I'd be okay with this change in general but just want to mention that up front. EDIT: Also, don't worry about implementing that now, we can fix extensions later, I just am thinking out loud here. |
This is what we've intended in the long run, but unfortunately in the mean time we have published some docs that rely on the IDs having a degree of re-usability, e.g. here: https://docs.dagger.io/cli/389936/run-pipelines-cli I think for those examples at least we can just update them to wrap the whole script in a
I think for almost all use cases this is totally fine; the memory overhead is essentially a factor of how many IDs you've used in the session so far, which isn't worse than the worst case today where all those IDs are being sent in memory as part of requests. Today it's a bit more spiky in that the memory goes down when the request isn't in flight, but I really doubt this will be a bottleneck. If we do run into issues, we can also find ways of decreasing the size of the unhashed IDs, even via something as dumb as just compressing them. The one special use case I can think of where this may matter is the playground cc @marcosnils I don't think we'd ever want to use an LRU cache, I don't think there's any way of dealing with the ID being kicked from it besides returning an error to the user, which wouldn't make any sense to them.
I'm very ambivalent, but would probably air on the side of sha256 too just because it's more well understood and from the stdlib. And on the off-chance we for whatever reason actually want these IDs to be cryptographically secure someday, then we'll already have that on solid footing. I'm sure xxh3 is totally fine too though |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
Closing this for now. We can re-assess once the dust has settled around entrypoints/extensions. The only reason I still wanted this was to have shorter IDs in the TUI with |
Currently
ContainerID,FileID, andDirectoryIDare gigantic strings because they are self-contained values that store the instructions for creating them.I noticed during testing that a these can be pretty expensive to deal with. Dagger was burning a ton of memory on my laptop and even caused my OS to crash. I think the root cause of this was really #5012 but either way I don't think we necessarily wanted these to be giant values forever.
This PR maintains their content-addressed quality by replacing them with a
digest.Digestwhich maps to an internal cache fromdigest.Digestto*Container,*Directory, and*File.New caveats to consider:
digest.Digestjust because that's more common everywhere else. Curious if anyone has an opinion on this.I'm curious if that second point affects anyone. I don't think we're really focused on 'infinite sessions' right now so my hunch is nothing would break with this change, but it's worth picking apart a bit more.