perf(cloudfoundry): skip dead per-space enrichment on prewarm drain - #5614
Merged
norman-abramovitz merged 2 commits intoJul 10, 2026
Conversation
The EndpointDataService prewarm drains the whole space list purely as a guid->name catalog (routes/users/audit-events resolvers read only name and guid). getNativeSpaces was enriching every returned space with app and route counts that nothing displays off this list; the counts shown on the org->spaces tab come from getNativeOrgSpaces instead. On large foundations that enrichment is ~8 sequential filtered CAPI round-trips per page and dominates the drain cost. Add ?enrich=none to getNativeSpaces (reusing the existing skip branch) and have the prewarm drains (loadSpaces, refreshSpaces) pass it via a new drainCfPages extraParams argument. Default requests and getNativeOrgSpaces are unchanged. Measured on a 2511-space foundation: page fetch 5.5s -> 1.8s, same 500 spaces returned.
The perf change appends enrich=none to the two spaces-drain requests, but SPACES_FULL_URL still matched the un-enriched URL, so every expectOne(SPACES_FULL_URL) left the real request open — httpMock.verify() then threw in afterEach and cascaded across the suite (44/50 failed). Align the constant with the request the drain now makes.
nabramovitz
force-pushed
the
norm/fix/stratos-space-drain-skip-dead-enrichment
branch
from
July 10, 2026 11:59
a34bd9f to
1eb044b
Compare
nabramovitz
deleted the
norm/fix/stratos-space-drain-skip-dead-enrichment
branch
July 24, 2026 12:36
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.
Problem
EndpointDataServiceprewarms a hot cache by draining the whole space list (loadSpaces/refreshSpaces→drainCfPages('/pp/v1/cf/spaces/{cnsi}')). That hitsgetNativeSpaces, whose default path enriches every returned space with app and route counts viafetchAppCountsForSpaces/fetchRouteCountsForSpaces— chunked, sequential filtered CAPI round-trips, ~8 per page.Nothing displays those per-space counts off the all-spaces list. Every consumer of
EndpointDataService.spaces()(routes / users / audit-events / space-roles resolvers, add-edit-space) reads onlyname+guid. The counts shown on the org→spaces tab come from a different handler,getNativeOrgSpaces, which is untouched here. So the prewarm enrichment is computed and discarded.On a large foundation the enrichment dominates the drain cost and, fanned out across the prewarm's pages, saturates the jetstream→CF proxy path.
Fix
getNativeSpaceshonors?enrich=none, routing through the existing skip branch so no count fetches are issued. Default requests andgetNativeOrgSpacesare unchanged.drainCfPagesgains anextraParamsargument; the two prewarm drains passenrich=none. Only the speculative space prewarm is affected — orgs/apps drains are untouched.Measurement
Foundation with 2511 spaces but only 54 apps / 54 routes (so the counts are cheap for CF to compute — the cost is the serial round-trips, not CF):
?enrich=noneRaw
cf curl /v3/spaces?per_page=500is ~1.5s, soenrich=noneis at the CF floor.Tests
Adds
TestGetNativeSpaces_EnrichNoneSkipsCounts— assertsenrich=noneskips app/route enrichment with no guids filter present while still returning the full space list. Fullplugins/cloudfoundrypackage passes.