Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/filetypes: lazily load types.cue
Don't parse and compile the CUE code until the first time it's needed. This helps with developing or debugging the evaluator, as one can run unit tests or the debugger on a slightly broken or instrumented version of the evaluator without necessarily having to evaluate internal/filetypes/types.cue before anything else. On top of that, this shaves off about 6ms from the init time cost of cmd/cue, which should help any command that makes no use of filetypes to interpret arguments or files such as `cue help` or `cue login`. │ old │ new │ │ sec/op │ sec/op vs base │ CuelangOrgGoCmdCue 7.302m ± 0% 1.425m ± 1% -80.48% (p=0.000 n=10) │ old │ new │ │ B/op │ B/op vs base │ CuelangOrgGoCmdCue 3.580Mi ± 0% 1.257Mi ± 0% -64.90% (p=0.000 n=10) │ old │ new │ │ allocs/op │ allocs/op vs base │ CuelangOrgGoCmdCue 45.50k ± 0% 10.19k ± 0% -77.60% (p=0.000 n=10) In the future we might try to redesign internal/filetypes so that its logic does not depend on the evaluator, as that is a form of issue for bootstrapping cmd/cue's basic commands. However, for now the speed-ups in previous CLs plus the init time saving in this CL are enough to stop filetypes from being an immediate issue. Fixes #3024. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I24d96501a673c49e4cc59960307923fbdacbf3f6 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193639 Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Roger Peppe <rogpeppe@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
- Loading branch information