Repository navigation
Cache persistence off by default, rename mccode-antlr cache ir-build to ... build - #402
Merged
Merged
Conversation
The component cache was keyed on a .comp file's own mtime only, so editing the parent of `DEFINE COMPONENT b INHERIT a` left b's cached IR -- in memory and in its sidecar -- reporting a's old contents until b itself was touched. Each cache entry now records the mtime of every source file it was built from: itself plus every component resolved through Reader.get_component while it was parsed, transitively. A hit requires all of them to match exactly, which also rejects a .comp whose mtime moved backwards (rsync -a of an older file over a newer sidecar). Sidecars store these sources relative to their own directory, so a tree copied with mtimes preserved keeps its cache. The sidecar layout changes, so the cache format is now 5. `cache ir-build` and `ir-clean --stale` use the same freshness check.
Translation parses every component's SHARE, DECLARE and USERVARS blocks, and each runtime library they %include, to find C typedefs and declarations. That parse is cached by content hash, but nothing pre-built the cache, so a read-only image (stacktainer-splitrun) re-parsed them in every process: 1.3 s for ILL_H142 and 2.5 s for cryostat_example, against 0.34 s warm. ir-build now constructs the C translator for a one-instance instrument of each component it builds or finds up to date, which parses exactly the blocks a real translation would. Only an instrument's own USERVARS are left for translation time. A component that cannot be translated (e.g. a missing %include file) is reported separately and does not count as an IR error.
`cache build` pre-builds both translation caches, so the IR-specific name no longer fits. `cache ir-build` remains as a deprecated spelling that warns and then runs `cache build`. Component IR sidecars are now written and read only when the new `cache.component_ir` configuration value is true (e.g. MCCODEANTLR_CACHE__COMPONENT_IR=true); it defaults to false. Re-parsing a component costs ~0.3 s per translation process, while sidecars written into source trees have repeatedly served stale IR and leaked into published registries. They remain worthwhile for a prebuilt, read-only cache such as a container image, which can opt in. The in-memory level is unchanged, so long-lived processes lose nothing. String values, as stored by `mccode-antlr config set`, are parsed rather than taken as truthy. With sidecars disabled, `cache build` says so and only warms the C typedef cache. The CLI docs also drop a nonexistent `--download` option and list `--tag` and `--flavor none`.
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.
Since
.compfile parsing was improved drastically, the on-diskCompIR cache causes more problems than it seems to be worth for most cases.This PR turns off on-disk caching by default, and adds C
typedefcaching to the, now renamed,mccode-antlr cache buildcommand. Both the Comp IR cache and C typedef cache are kept in memory to ensure they continue to help with repeated translations in a single process, e.g., live parsing of a.instrfile by a language server.One case where the
cache buildstep makes sense is a read-only pre-baked container image which contains all of McStas' component files, and the newconfuseconfiguration key is provided to ensure this use case is still accessible.