docparse: speed up doc generation via parallel parsing and package preloading - #115
Merged
Conversation
Coverage Report for CI Build 28533681959Coverage increased (+1.8%) to 55.423%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
shane-tw
force-pushed
the
perf/parallel-file-parsing
branch
from
July 1, 2026 16:51
9913d8d to
2debc05
Compare
…eloading - Parse all source files concurrently in FindComments using a WaitGroup; each goroutine owns its own token.FileSet. - Cache parsed *ast.File values by absolute path (astFileCache sync.Map) so getDecls reuses already-parsed ASTs instead of re-reading files. - Parallel-parse any uncached files inside getDecls as well. - Batch-resolve all imported packages with a single packages.Load call (preloadPackages) before the serial endpoint-processing loop, pre-populating resolvedPkgCache and declsCache to eliminate cold build.Import calls. - Cache both successes and failures in resolvedPkgCache (pkgResult) so short package names that fail the first lookup are not retried repeatedly. - Emit progress lines to stderr so users can see what is happening.
shane-tw
force-pushed
the
perf/parallel-file-parsing
branch
from
July 1, 2026 16:57
2debc05 to
e03ce62
Compare
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.
What changed
Parallel file parsing in
FindCommentsPreviously
FindCommentsparsed source files serially (one at a time in a loop). Now all files are parsed concurrently using aWaitGroup, with each goroutine owning its owntoken.FileSet. The parsed results are collected into a[]parsedFileslice before any serial processing begins.Cross-phase AST reuse (
astFileCache)FindCommentsandgetDeclsboth callparser.ParseFileon the same set of source files. The parsed*ast.Filevalues are now cached in async.Map(astFileCache) keyed by absolute path.getDeclschecks this cache first; files already parsed during comment extraction are reused at zero I/O cost. Files not in the cache are parsed concurrently insidegetDeclsas well.Batch package preloading (
preloadPackages)Before the serial endpoint-processing loop, all packages imported by the scanned files are resolved in a single
packages.Loadcall (onego listinvocation). The results are used to pre-populateresolvedPkgCacheanddeclsCache, so the serial loop hits no coldbuild.Importcalls.Failure caching in
resolvedPkgCachePackage lookups are cached as a
pkgResult{pkg, err}struct — both successes and failures. Short local names (e.g."payload") that cannot be resolved directly always failedbuild.Import, but without caching those failures the same failed call repeated for every unique type reference. Now each import path is tried at most twice per run.Test plan
go test ./...passes