Skip to content

perf(chat): create the Gemini prompt cache in the background - #1450

Open
raghvendradhakar wants to merge 1 commit into
juspay:assistfrom
raghvendradhakar:perf/chat-prompt-cache-background
Open

raghvendradhakar wants to merge 1 commit into
juspay:assistfrom
raghvendradhakar:perf/chat-prompt-cache-background

Conversation

@raghvendradhakar

Copy link
Copy Markdown
Contributor

On a cache miss, resolve_prompt_cache awaited caches.create inline under one global lock, so the first message per pod, template and hour waited 2.7-3.9 s for Vertex to build the cache, and other templates queued behind it.

A miss now returns None (the caller already sends the full prefix, which is as fast as a cached request at these sizes) and creates the cache in a background task, one per key. An entry inside the refresh margin is still served while its replacement is created, and is no longer served in its last 60 s. A failed create still cools down for 600 s, but no longer stops a live cache from being served.

On a cache miss, resolve_prompt_cache awaited caches.create inline under
one global lock, so the first message per pod, template and hour waited
2.7-3.9 s for Vertex to build the cache, and other templates queued
behind it.

A miss now returns None (the caller already sends the full prefix, which
is as fast as a cached request at these sizes) and creates the cache in a
background task, one per key. An entry inside the refresh margin is still
served while its replacement is created, and is no longer served in its
last 60 s. A failed create still cools down for 600 s, but no longer stops
a live cache from being served.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 261b8ccd-70b7-4189-a6de-df61a58f2cb1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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