Skip to content

Skip expensive parser gem YARD generation when RBS collection available - #1339

Open
apiology wants to merge 2 commits into
castwide:masterfrom
apiology:skip-yard-when-rbs-suffices
Open

Skip expensive parser gem YARD generation when RBS collection available#1339
apiology wants to merge 2 commits into
castwide:masterfrom
apiology:skip-yard-when-rbs-suffices

Conversation

@apiology

@apiology apiology commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Problem: Caching the parser gem spends over a minute building YARD documentation that its RBS types already describe, and every cold cache pays it.

$ time solargraph cache parser
real  1m16.070s

Solargraph resolves parser through RBS on every one of those runs, so the YARD pass is largely redundant work sitting between the user and a usable cache.

Solution: PinCache.suppress_yard_cache? reports true for a gem named in YARD_SUPPRESSED_GEMS whose RBS types resolved, and the four places that decide to build YARD pins — DocMap#cache, Shell#cache, the named-gem path in Shell#gems, and Shell#do_cache — skip the build when it does, taking that same command to 0.593s.

Verified that Solargraph (an extensive parser gem user) is not affected in typechecking by the removed YARD information.

🤖 Generated with Claude Code

Building YARD documentation for the parser gem takes over a minute on
a cold cache, while its RBS collection types already describe the
API. Caching parser measured 73.13s with YARD and 0.08s without.

PinCache.suppress_yard_cache? reports true for a gem named in
YARD_SUPPRESSED_GEMS whose RBS types resolved. Every place that
decides to build YARD pins now consults it: DocMap#cache,
Shell#cache, the named-gem path in Shell#gems, and Shell#do_cache.

DocMap#deserialize_combined_pin_cache treats a suppressed gem as
having an empty YARD half rather than an uncached one, so combined
pins still get written and the gem stops reading as uncached on
every load.

The trade-off is coverage: parser yields 9,175 combined pins with
YARD and 178 from RBS alone. Much of that gap is likely private and
generated node classes, but that has not been verified against what
users complete on.
undercover reported the method as 0.0% covered on this branch. The
existing #cache and #gems examples reach it only through a subprocess
shim, so none of its lines record coverage.

The new examples call the private method directly with a stubbed
Workspace, RbsMap and PinCache, and let the real
PinCache.suppress_yard_cache? decide: a suppressed gem whose RBS
collection resolves skips the YARD build, an unresolved cache key does
not, and a gem outside the suppression list does not.
@apiology apiology changed the title Skip YARD pins when RBS collection types resolve Skip parser gem YARD pins when RBS collection available Sep 6, 2026
@apiology apiology changed the title Skip parser gem YARD pins when RBS collection available Skip expensive parser gem YARD generation when RBS collection available Sep 6, 2026
@apiology
apiology marked this pull request as ready for review September 6, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant