Repository navigation
Conversation
Dang moves from the merge of vito/dang#205 to the merge of vito/dang#213, which adds ParseSourceFile. In between are the v2.2.0 and v2.3.0 releases and vito/dang#214, which change what Dang modules see: - The dang.toml that governs a module's source, found by walking up to the repository root, now sets the Dang version its source parses and evaluates as. A module with none keeps the newest version. A malformed dang.toml, which was ignored before, now fails the module's load. - A module's own top-level declarations shadow builtins of the same name (vito/dang#212). - JSON, YAML and TOML decode into Map[T] (vito/dang#214). - The Dang language skill the engine serves describes these. The engine still chooses a module's Dagger API version itself; the Dagger version a dang.toml can declare doesn't change it. Signed-off-by: Erik Sipsma <[email protected]>
Loading a Dang module parses its source three times: once for its declared type names, once in DeclareDir, and once more to put its object directives back on its types. Only DeclareDir's parse went through the syntax cache, so on a fresh engine every module paid for two extra parses before its first call. For dagger/go's Go module each costs 147 ms and 65 MB of allocations, against 6 ms and 2 MB to copy the file from the cache. The engine's own two reads now parse through the same cache with dang.ParseSourceFile, at the module's Dang version, so a module's source is parsed once for all three. Signed-off-by: Erik Sipsma <[email protected]>
Their parse now follows the module's dang.toml, so the names depend on the Dang version as well as the source: a module whose dang.toml was broken, or that changed only its version, kept the names found before. The memo key now includes the version, and a dang.toml that can't be read is not remembered. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Contributor
Author
|
Closing in favor of #14953, which carries these four commits (parsing a Dang module's source once at load, through Dang's syntax cache) together with the Dang pin they need. |
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.
Loading a Dang module parses its source three times: once for the module's own type names, once in
DeclareDir, and once more to put its object directives back on its types. Since #14802, the engine keeps parsed Dang source in a syntax cache, but onlyDeclareDir's parse goes through it. So on a fresh engine, every module still pays for two extra parses before its first call.The engine's own two reads now go through the same cache with
dang.ParseSourceFile(vito/dang#213), at the module's Dang version. A module's source is parsed once for all three.What it saves, by a Go benchmark on 16 Graviton4 cores:
go.dang, 47 KB)gomodmodule (35 KB)That's about 0.44 CPU-s and 200 MB of allocations off a fresh engine's first load of dagger/go. On a warm engine, or one that keeps module definitions in its persistent cache, the load doesn't run, so nothing changes there.
The type-name memo now also keys on the Dang version. The names' parse now follows the module's
dang.toml. Without the version in the key, fixing only a brokendang.tomlkept the names found before. Adang.tomlthat can't be read isn't remembered.The Dang move changes more than caching
ParseSourceFileis on vito/dang main, past the v2.2.0 and v2.3.0 releases, so this moves Dang there. These come with it, and reach every Dang module:dang.tomlsets the Dang version. That's the nearestdang.toml, walking up to the repository root, so it can be in a parent directory. It sets the version the source parses and runs as. A module with none keeps the newest version. A malformeddang.toml, which was ignored before, now fails the module's load.Map[T](Decode JSON/YAML/TOML into Map[T] vito/dang#214).The engine still chooses a module's Dagger API version itself. A Dagger version declared in
dang.tomldoesn't change it. #14958 moves Dang to v2.3.0 with engine-side version handling, so whichever lands second rebases itsgo.mod.Tests
go buildof the engine, CLI andcore/..., andgo test -race ./core/sdk/dang/..., pass. A new test covers repairing a brokendang.tomlwithout changing the source.ParseSourceFile's own tests are in vito/dang.