Repository navigation
Speed up code generation, test compilation, and require Go 1.27.3 - #4067
Merged
Merged
Conversation
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.
Generating code and running the generator test suites on large multi-service designs spent most of its time in repeated attribute deep copies, template re-parsing, full-file import formatting, reflection path allocations during design snapshot checks, and sequential
go test -mod=modsubprocesses. This change reduces bothgoa genexecution time and the code generation test suite runtime while upgrading the module minimum to Go 1.27.3.During code generation:
codegen.mappedObjectDefinitionpreviously calledexpr.NewMappedAttributeExpr, which recursively cloned entire nested attribute graphs (DupAtt) just to strip:tagsuffixes from top-level object fields during transform planning.expr.NewShallowMappedAttributeExprnow copies only the top-level object attribute and its immediate field slice while preserving sharedUserTypeorigin identity across sibling fields.SectionTemplate.Writenow caches parsedtext/templateinstances for templates using the defaultTemplateFuncs()map instead of reparsing template text on every rendered section.finalizeGoSourcenow formats only the package and import header through the first non-import declaration whenimports.Process(FormatOnly: true) runs on files without//linedirectives, splicing the formatted import block onto the already-printed AST body instead of re-parsing and re-printing the entire file a second time.captureDesignStatenow reuses a growable path buffer, caches struct field metadata perreflect.Type, and hashes directly intofnv.New128a()without allocating intermediate path strings on every visited node.In the codegen test suites (
codegen,codegen/service,codegen/generator,http/codegen,grpc/codegen, andjsonrpc/codegen), temporary test modules now pre-tidygo.modandgo.sumonce per test binary and compile generated packages in parallel using-mod=readonly(andgo buildwhen no generated*_test.gofiles exist), cutting the combined test run from ~222s to ~56s.