Skip to content

Set service worker/cachestorage quota to 6 MiB - #12441

Merged
sacuff merged 1 commit into
youtube:mainfrom
sacuff:cache
Oct 27, 2026
Merged

sacuff merged 1 commit into
youtube:mainfrom
sacuff:cache

Conversation

@sacuff

@sacuff sacuff commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Caps the Service Worker and CacheStorage per-origin quota at 6 MiB,
since Cobalt should only need to cache from youtube.com. Previously the
quota was 60% of the cache volume (80% pool x 75% per origin).

CobaltContentBrowserClient::GetCacheQuotaSettings overrides the default
quota calculation and also prevents QuotaManager from evicting the
YouTube bucket, which deletes CacheStorage and unregisters the Service
Worker:

  • pool_size is 12 MiB (2x the quota), so usage-based eviction, which
    starts at 70% of pool_size (8.4 MiB), cannot trigger below the quota.
  • should_remain_available is 0, which disables disk-pressure eviction.
    The default (10% of the volume, 2.4 MiB on a 24 MiB cache partition)
    exceeds the 1 MiB headroom in the cache directory budget.

The non-HTTP cache budgets (5 MiB code cache, 6 MiB CacheStorage, 1 MiB
headroom) are now shared constants so the HTTP cache reserve and the
CacheStorage quota cannot drift apart.

CacheStorage browsertests now use the same 6 MiB quota and verify that
writes beyond it fail with QuotaExceededError.

Bug: 576737712

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Override cache quota settings

Implement a Cobalt-specific override for GetCacheQuotaSettings to
integrate Starboard's kSbMaxSystemPathCacheDirectorySize into the
storage quota calculation.

This change also expands the per-origin cache pool ratio from the
Chromium default of 60% to 100%. Since Cobalt primarily serves content
from a single origin, it can more efficiently utilize the entire
available cache space for that origin.

Bug: 555871214

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ⏳ PENDING Checks are running
CI / android ⏳ PENDING Checks are running
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ✅ PASS Passed
@sacuff
sacuff force-pushed the cache branch 2 times, most recently from ed3977d to 9ff7327 Compare September 29, 2026 19:46
@sacuff
sacuff force-pushed the cache branch 2 times, most recently from 247d1dd to ae3db13 Compare October 13, 2026 19:53
@sacuff
sacuff force-pushed the cache branch 3 times, most recently from 153c29c to 3584e26 Compare October 26, 2026 23:32
@sacuff sacuff changed the title Cobalt override for GetCacheQuotaSettings Oct 26, 2026
@sacuff
sacuff marked this pull request as ready for review October 26, 2026 23:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements custom cache quota settings for Cobalt, enforcing a 6 MiB CacheStorage quota pool and sizing the HTTP cache around this reservation. It adds the GetCacheQuotaSettings method to CobaltContentBrowserClient, along with corresponding unit tests and integration tests to verify quota enforcement. The review feedback suggests adding a defensive null check for device_info_helper to prevent potential null pointer dereferences, and calculating must_remain_available before pool_size to ensure the quota pool does not exceed actual writable space on small disks, aligning with standard Chromium behavior.

Caps the Service Worker and CacheStorage per-origin quota at 6 MiB,
since Cobalt should only need to cache from youtube.com. Previously the
quota was 60% of the cache volume (80% pool x 75% per origin).

CobaltContentBrowserClient::GetCacheQuotaSettings overrides the default
quota calculation and also prevents QuotaManager from evicting the
YouTube bucket, which deletes CacheStorage and unregisters the Service
Worker:
- pool_size is 12 MiB (2x the quota), so usage-based eviction, which
  starts at 70% of pool_size (8.4 MiB), cannot trigger below the quota.
- should_remain_available is 0, which disables disk-pressure eviction.
  The default (10% of the volume, 2.4 MiB on a 24 MiB cache partition)
  exceeds the 1 MiB headroom in the cache directory budget.

The non-HTTP cache budgets (5 MiB code cache, 6 MiB CacheStorage, 1 MiB
headroom) are now shared constants so the HTTP cache reserve and the
CacheStorage quota cannot drift apart.

CacheStorage browsertests now use the same 6 MiB quota and verify that
writes beyond it fail with QuotaExceededError.

Bug: 576737712
@sacuff
sacuff enabled auto-merge (squash) October 27, 2026 21:02
@sacuff
sacuff merged commit a49334a into youtube:main Oct 27, 2026
750 of 759 checks passed
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 27, 2026
Refer to original PR: #12441

Caps the Service Worker and CacheStorage per-origin quota at 6 MiB,
since Cobalt should only need to cache from youtube.com. Previously the
quota was 60% of the cache volume (80% pool x 75% per origin).

CobaltContentBrowserClient::GetCacheQuotaSettings overrides the default
quota calculation and also prevents QuotaManager from evicting the
YouTube bucket, which deletes CacheStorage and unregisters the Service
Worker:
- pool_size is 12 MiB (2x the quota), so usage-based eviction, which
  starts at 70% of pool_size (8.4 MiB), cannot trigger below the quota.
- should_remain_available is 0, which disables disk-pressure eviction.
  The default (10% of the volume, 2.4 MiB on a 24 MiB cache partition)
  exceeds the 1 MiB headroom in the cache directory budget.

The non-HTTP cache budgets (5 MiB code cache, 6 MiB CacheStorage, 1 MiB
headroom) are now shared constants so the HTTP cache reserve and the
CacheStorage quota cannot drift apart.

CacheStorage browsertests now use the same 6 MiB quota and verify that
writes beyond it fail with QuotaExceededError.

Bug: 576737712

(cherry picked from commit a49334a)
@andrewsavage1 andrewsavage1 added the cp-27.lts Cherry Pick to the 27.lts branch label Oct 28, 2026
briantting pushed a commit that referenced this pull request Nov 3, 2026
Refer to original PR: #12441

Caps the Service Worker and CacheStorage per-origin quota at 6 MiB,
since Cobalt should only need to cache from youtube.com. Previously the
quota was 60% of the cache volume (80% pool x 75% per origin).

CobaltContentBrowserClient::GetCacheQuotaSettings overrides the default
quota calculation and also prevents QuotaManager from evicting the
YouTube bucket, which deletes CacheStorage and unregisters the Service
Worker:
- pool_size is 12 MiB (2x the quota), so usage-based eviction, which
  starts at 70% of pool_size (8.4 MiB), cannot trigger below the quota.
- should_remain_available is 0, which disables disk-pressure eviction.
  The default (10% of the volume, 2.4 MiB on a 24 MiB cache partition)
  exceeds the 1 MiB headroom in the cache directory budget.

The non-HTTP cache budgets (5 MiB code cache, 6 MiB CacheStorage, 1 MiB
headroom) are now shared constants so the HTTP cache reserve and the
CacheStorage quota cannot drift apart.

CacheStorage browsertests now use the same 6 MiB quota and verify that
writes beyond it fail with QuotaExceededError.

Bug: 576737712

(cherry picked from commit a49334a)
@sacuff
sacuff deleted the cache branch November 4, 2026 23:14
briantting pushed a commit that referenced this pull request Nov 11, 2026
… to 6 MiB

Refer to original PR: #12441

Caps the Service Worker and CacheStorage per-origin quota at 6 MiB,
since Cobalt should only need to cache from youtube.com. Previously the
quota was 60% of the cache volume (80% pool x 75% per origin).

CobaltContentBrowserClient::GetCacheQuotaSettings overrides the default
quota calculation and also prevents QuotaManager from evicting the
YouTube bucket, which deletes CacheStorage and unregisters the Service
Worker:
- pool_size is 12 MiB (2x the quota), so usage-based eviction, which
  starts at 70% of pool_size (8.4 MiB), cannot trigger below the quota.
- should_remain_available is 0, which disables disk-pressure eviction.
  The default (10% of the volume, 2.4 MiB on a 24 MiB cache partition)
  exceeds the 1 MiB headroom in the cache directory budget.

The non-HTTP cache budgets (5 MiB code cache, 6 MiB CacheStorage, 1 MiB
headroom) are now shared constants so the HTTP cache reserve and the
CacheStorage quota cannot drift apart.

CacheStorage browsertests now use the same 6 MiB quota and verify that
writes beyond it fail with QuotaExceededError.

Bug: 576737712

(cherry picked from commit a49334a)
briantting pushed a commit that referenced this pull request Nov 12, 2026
…ta to 6 MiB (#13938)

Automated cherry-pick roll to staging.

Original pull requests:
- #12441

CONFLICTED files:
```
cobalt/browser/cache_storage_browsertest.cc
```

⚠️ This PR has conflicts that must be resolved manually (don't forget to
update the `.github/AUTOROLL` file). Use the following commands to
checkout the branch locally and resolve the conflicts in a separate
commit:

```bash
gh pr checkout <pull_request_number> -R youtube/cobalt

# Resolve conflicts and update .github/AUTOROLL then
git add <resolved_files>

# Copy CONFLICTED commit's message and metadata
# Replace CONFLICTED in title with RESOLVED
git commit -c <conflicted_sha>

git push origin autoroll-main-to-staging
```

---------

Co-authored-by: Sean Cuff <sacuff@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp-27.lts Cherry Pick to the 27.lts branch kokoro:run

3 participants