Skip to content

feat: slow plan cache docs#262

Open
SkArchon wants to merge 5 commits intomainfrom
milinda/eng-9010-router-investigate-customizing-our-planner-cache-to-consider
Open

feat: slow plan cache docs#262
SkArchon wants to merge 5 commits intomainfrom
milinda/eng-9010-router-investigate-customizing-our-planner-cache-to-consider

Conversation

@SkArchon
Copy link
Contributor

@SkArchon SkArchon commented Mar 9, 2026

Description

This PR adds documentation for the feature here wundergraph/cosmo#2611

Summary by CodeRabbit

  • Documentation
    • Added detailed docs for the Slow Plan Cache: behavior, warmup sources, eviction, tuning, and observability (slow-plan-cache hits).
    • Introduced two public configuration options: engine.slow_plan_cache_size and engine.slow_plan_cache_threshold, with example YAML and notes about usage when in_memory_fallback is enabled.
    • Clarified metrics/monitoring docs to show when a plan was served from the main cache versus the slow plan cache.

Checklist

  • I have validated my changes locally using mintlify dev
  • I have validated my changes are working as expected by looking at the preview deployment
  • All links in my documentation work correctly
  • All images render properly
  • Code examples are tested and formatted correctly
  • If I added new pages, they are included in the navigation (docs.json)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Walkthrough

Introduces a bounded "slow plan cache" for preserving expensive/slow-to-plan GraphQL execution plans across reloads, adds router engine configuration options to tune its threshold and size, updates cache-warming behavior and examples, and clarifies metrics/observability to indicate slow plan cache usage.

Changes

Cohort / File(s) Summary
Router configuration
docs/router/configuration.mdx
Added engine.slow_plan_cache_size and engine.slow_plan_cache_threshold configuration fields, documented defaults and usage when cache_warmup.in_memory_fallback is enabled, and updated example YAML.
Concepts & cache mechanics
docs/concepts/cache-warmer.mdx
Rewrote cache-warmer doc to replace generic in-memory fallback with a detailed Slow Plan Cache: promotion criteria (planning time > threshold), bounded size & eviction, warmup behavior across reloads, config keys (engine.slow_plan_cache_size, engine.slow_plan_cache_threshold, cache_warmup.in_memory_fallback), tuning, and observability notes.
Metrics & monitoring
docs/router/metrics-and-monitoring.mdx
Clarified GraphQL metric attribute wg.engine.plan_cache_hit to indicate whether a plan came from the main execution plan cache or the slow plan cache; updated descriptions accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The PR title 'feat: slow plan cache docs' clearly and concisely describes the main change: adding documentation for the slow plan cache feature across multiple documentation files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
📝 Coding Plan for PR comments
  • Generate coding plan

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/concepts/cache-warmer.mdx (1)

164-173: Add direct links from observability to setup/querying docs.

This section lists the new signals well, but it would be easier to navigate if readers could jump straight to the config and metrics reference pages from here.

↗️ Suggested doc cross-links
 ### Observability
 
 When the expensive query cache is enabled, the following observability signals are available:
@@
 These attributes are only emitted when `in_memory_fallback` is enabled. Existing users who do not enable this feature will see no change in their telemetry.
+
+For setup details, see [Router Configuration](/router/configuration#router-engine-configuration). For querying and interpreting the emitted metrics, see [Metrics & Monitoring](/router/metrics-and-monitoring).

As per coding guidelines, "Link between related documentation pages".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/concepts/cache-warmer.mdx` around lines 164 - 173, Update the "###
Observability" section to add direct cross-links to the relevant setup and
querying docs: link the config key pages for in_memory_fallback and
engine.debug.enable_cache_response_headers, link the metrics reference pages
that document router.graphql.operation.planning_time and the Prometheus label
wg_engine_expensive_plan_cache_hit, and link the tracing docs that show the
Operation - Plan span and wg.engine.expensive_plan_cache_hit attribute so
readers can jump from the observability signals to configuration and
metrics/tracing usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/concepts/cache-warmer.mdx`:
- Around line 164-173: Update the "### Observability" section to add direct
cross-links to the relevant setup and querying docs: link the config key pages
for in_memory_fallback and engine.debug.enable_cache_response_headers, link the
metrics reference pages that document router.graphql.operation.planning_time and
the Prometheus label wg_engine_expensive_plan_cache_hit, and link the tracing
docs that show the Operation - Plan span and wg.engine.expensive_plan_cache_hit
attribute so readers can jump from the observability signals to configuration
and metrics/tracing usage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4abafec7-aa91-4306-8602-dd3ad3d211c4

📥 Commits

Reviewing files that changed from the base of the PR and between 017486a and 71099f4.

📒 Files selected for processing (3)
  • docs/concepts/cache-warmer.mdx
  • docs/router/configuration.mdx
  • docs/router/metrics-and-monitoring.mdx

@SkArchon SkArchon marked this pull request as ready for review March 9, 2026 15:04
@SkArchon SkArchon requested review from a team as code owners March 9, 2026 15:04
@SkArchon SkArchon requested review from StarpTech, thisisnithin and ysmolski and removed request for a team March 9, 2026 15:04
@SkArchon SkArchon closed this Mar 11, 2026
@SkArchon SkArchon reopened this Mar 12, 2026
Resolve conflict in metrics-and-monitoring.mdx: keep plan fallback cache
description update and new Cost Control metrics section from upstream.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/concepts/cache-warmer.mdx (1)

176-178: Add a direct link to the metrics reference from this observability note.

This section introduces new observability semantics, but it doesn't point readers to the metrics reference page. A direct link here would make the new behavior easier to discover.

🔗 Suggested addition
 Plan fallback cache hits are counted as regular plan cache hits — the `wg.engine.plan_cache_hit` attribute is set to `true` for hits from either the main cache or the fallback cache. There is no separate observability signal for fallback cache hits.
+
+For the full GraphQL metrics reference, see [Metrics and Monitoring](/router/metrics-and-monitoring).

As per coding guidelines, "Link between related documentation pages".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/concepts/cache-warmer.mdx` around lines 176 - 178, In the
"Observability" section update the paragraph that mentions
wg.engine.plan_cache_hit to include a direct link to the metrics reference page;
edit the text around "There is no separate observability signal for fallback
cache hits." to append a short inline link like "(see metrics reference)"
pointing to the metrics reference doc so readers can jump directly from the
Observability note to the full metrics documentation for
wg.engine.plan_cache_hit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/concepts/cache-warmer.mdx`:
- Around line 122-123: The bullets overstate guarantees of preserving queries
above plan_fallback_threshold; clarify that retention is only
eligibility-limited by the bounded plan_fallback_cache_size so some eligible
entries may be evicted once the cache fills. Update the two affected bullets
(the instances referencing plan_fallback_threshold and the claim about
eliminating reload spikes) to mention plan_fallback_cache_size explicitly and
use language like "eligible for retention" or "retained while cache capacity
allows" rather than absolute preservation or elimination of spikes.

---

Nitpick comments:
In `@docs/concepts/cache-warmer.mdx`:
- Around line 176-178: In the "Observability" section update the paragraph that
mentions wg.engine.plan_cache_hit to include a direct link to the metrics
reference page; edit the text around "There is no separate observability signal
for fallback cache hits." to append a short inline link like "(see metrics
reference)" pointing to the metrics reference doc so readers can jump directly
from the Observability note to the full metrics documentation for
wg.engine.plan_cache_hit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c75bde8-f7b0-4534-be30-57288ceeb543

📥 Commits

Reviewing files that changed from the base of the PR and between 71099f4 and c41b633.

📒 Files selected for processing (3)
  • docs/concepts/cache-warmer.mdx
  • docs/router/configuration.mdx
  • docs/router/metrics-and-monitoring.mdx
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/router/metrics-and-monitoring.mdx
  • docs/router/configuration.mdx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
docs/concepts/cache-warmer.mdx (1)

115-116: ⚠️ Potential issue | 🟡 Minor

Qualify the “all queries” / “no spikes” guarantees.

These bullets still read as if lowering slow_plan_cache_threshold guarantees full preservation. In practice it only makes more queries eligible; actual retention is still capped by slow_plan_cache_size, so 1ns does not mean "all queries are cached" unless the slow cache can hold the whole working set. The "Eliminates reload spikes" wording should also be softened to the retained subset.

✏️ Suggested wording
-- **Coverage of expensive queries**: By default, queries with planning times above the threshold (5s) are preserved and warmed on reload, protecting slow-to-plan queries from cold-start latency. Users can lower the threshold to any positive duration (e.g., `slow_plan_cache_threshold: 100ms`) to capture all queries. Users can also set the duration to 1 nanosecond (`slow_plan_cache_threshold: 1ns`), this would ensure that all queries are cached in the fallback, and thus would be available to rewarm the cache upon reloads.
-- **Eliminates reload spikes for expensive queries**: You won't experience query planning spikes for queries above the threshold after configuration or schema reloads. Users can tune the threshold to cover more or fewer queries.
+- **Coverage of expensive queries**: By default, queries with planning times above the threshold (5s) become eligible for the slow plan cache and can be rewarmed on reload while `slow_plan_cache_size` has capacity. Lowering the threshold widens eligibility and usually requires a larger `slow_plan_cache_size`.
+- **Reduces reload spikes for retained expensive queries**: Queries retained in the slow plan cache avoid a re-plan after configuration or schema reloads. Users can tune the threshold and cache size to cover more or fewer queries.

-- **Lower threshold → more queries protected**: Setting `slow_plan_cache_threshold: 1ns` captures all queries regardless of planning time. This gives you full "carry forward everything" behaviour similar to preserving the entire plan cache.
+- **Lower threshold → more queries eligible**: Setting `slow_plan_cache_threshold: 1ns` makes every query eligible for the slow plan cache, subject to `slow_plan_cache_size`. You only get "carry forward everything" behaviour when the slow plan cache is large enough to hold the full working set.

Also applies to: 202-203

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/concepts/cache-warmer.mdx` around lines 115 - 116, Update the two
bullets that claim lowering slow_plan_cache_threshold (and the "Eliminates
reload spikes" statement) to qualify that eligibility does not equal full
retention: explicitly state that setting slow_plan_cache_threshold to a low
value (e.g., 1ns) only makes more queries eligible for caching but actual
preservation is limited by slow_plan_cache_size and available working set, and
change "Eliminates reload spikes" to language like "reduces reload spikes for
the subset retained in the slow plan cache" (referencing
slow_plan_cache_threshold and slow_plan_cache_size and apply the same softened
wording to the other occurrence in the file).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/concepts/cache-warmer.mdx`:
- Around line 91-94: The second bullet currently describes a cache hit after
main-cache eviction rather than a population path; update the phrasing for the
slow plan cache (referencing slow_plan_cache_threshold and TinyLFU) so it
describes retention/update on eviction (e.g., "On eviction: when TinyLFU evicts
a plan that exists in the slow plan cache, the slow cache retains/updates the
plan to avoid recomputation") or move the cache-hit behavior into the following
paragraph to keep lifecycle description consistent with Lines 166-167.

---

Duplicate comments:
In `@docs/concepts/cache-warmer.mdx`:
- Around line 115-116: Update the two bullets that claim lowering
slow_plan_cache_threshold (and the "Eliminates reload spikes" statement) to
qualify that eligibility does not equal full retention: explicitly state that
setting slow_plan_cache_threshold to a low value (e.g., 1ns) only makes more
queries eligible for caching but actual preservation is limited by
slow_plan_cache_size and available working set, and change "Eliminates reload
spikes" to language like "reduces reload spikes for the subset retained in the
slow plan cache" (referencing slow_plan_cache_threshold and slow_plan_cache_size
and apply the same softened wording to the other occurrence in the file).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e441373-0160-4791-96a2-b0ef610a496f

📥 Commits

Reviewing files that changed from the base of the PR and between 743ba3d and c0b7a32.

📒 Files selected for processing (2)
  • docs/concepts/cache-warmer.mdx
  • docs/router/configuration.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/router/configuration.mdx

@SkArchon SkArchon changed the title feat: expensive query cache docs feat: slow plan cache docs Mar 12, 2026
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