Repository navigation
cobalt: Cap Wasm compiled code cache at 1 MiB - #13670
Conversation
|
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
There was a problem hiding this comment.
Code Review
This pull request introduces a separate 1 MB cache budget for WebAssembly (Wasm) code in Cobalt, alongside the existing JS code cache, and propagates this configuration through the browser's code cache initialization path. The reviewer feedback strongly recommends refactoring the implementation to make the Wasm cache size settings and initialization parameters unconditionally available across all platforms. Removing the platform-specific #if BUILDFLAG(IS_COBALT) preprocessor guards from the shared content/ codebase aligns with upstream Chromium style guidelines and minimizes downstream maintenance overhead.
Caps the WebAssembly compiled code cache (Code Cache/wasm/) at 1 MiB while leaving the JavaScript compiled code cache (Code Cache/js/) at 5 MiB, and deducts the 1 MiB Wasm cache allocation from the default HTTP cache budget (kNonHttpReserveBytes increases from 12 MiB to 13 MiB). Bug: 576735653
andrewsavage1
left a comment
There was a problem hiding this comment.
lgtm, you could consider putting the constant in a completely cobalt-owned location but this is okay too
Add cobalt::features::kCobaltCodeCacheOptimization (disabled by default for controlled Finch/Mendel A/B experimentation) strictly within cobalt/browser/ without modifying Blink or base/: 1. Set WebPreferences::v8_cache_options to kCodeWithoutHeatCheck (cobalt_v8_code_cache_bypass_heat_check=true) instead of kDefault in CobaltContentBrowserClient::OverrideWebPreferences() so Launch youtube#1 after install, cache clear, or weekly JS updates produces deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5 MiB to 10 MiB (cobalt_code_cache_size_mb=10, clamped to <= 1024 MiB against 32-bit overflow while Wasm stays capped at 1 MiB from youtube#13670) so ~4.6 MB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Record Cobalt.Storage.CodeCache.ConfiguredMaxSizeKB and add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest. (HTTP disk cache quota tuning is split into standalone cobalt::features::kCobaltHttpCacheQuota.) Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 TAG=agy CONV=b25ebd57-fb39-4a16-96b6-a4c885da89b0
Add cobalt::features::kCobaltCodeCacheOptimization (disabled by default for controlled Finch/Mendel A/B experimentation) strictly within cobalt/browser/ without modifying Blink or base/: 1. Set WebPreferences::v8_cache_options to kCodeWithoutHeatCheck (cobalt_v8_code_cache_bypass_heat_check=true) instead of kDefault in CobaltContentBrowserClient::OverrideWebPreferences() so Launch youtube#1 after install, cache clear, or weekly JS updates produces deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5 MiB to 10 MiB (cobalt_code_cache_size_mb=10, clamped to [1, 1024] MiB against 32-bit overflow while Wasm stays capped at 1 MiB from youtube#13670) so ~5.5 MiB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest. (HTTP disk cache quota tuning is split into standalone cobalt::features::kCobaltHttpCacheQuota in youtube#13914.) Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 TAG=agy CONV=b25ebd57-fb39-4a16-96b6-a4c885da89b0
Introduce cobalt::features::kCobaltCodeCacheOptimization (FEATURE_DISABLED_BY_DEFAULT) strictly in cobalt/browser/ (zero upstream/Blink/base/ changes) to eliminate cold-start V8 Code Cache self-eviction and two-launch bytecode warmup lag: 1. Bypass V8's 2-visit HasHotTimestamp gate in CobaltContentBrowserClient::OverrideWebPreferences() via V8CacheOptions::kCodeWithoutHeatCheck (CobaltCodeCacheOptimization_bypass_heat_check=true) so Launch youtube#1 after install, cache clear, or weekly JS updates caches deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5242880 bytes (5 MiB) to 10485760 bytes (10 MiB) via CobaltCodeCacheOptimization_size_bytes (clamped to [1048576, 1073741824] bytes while Wasm stays capped at 1 MiB from youtube#13670) so ~5.5 MiB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Prefix Finch feature parameter names with the feature name per go/cobalt-finch-setup#naming-style-guide (youtube#13883), declare quota parameters directly in bytes (youtube#13914), and add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest (including combined composition with kCobaltHttpCacheQuota). Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625
…ng (#13558) ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625
…13670) (#14235) Refer to original PR: #13670 Caps the WebAssembly compiled code cache (`Code Cache/wasm/`) at 1 MiB while leaving the JavaScript compiled code cache (`Code Cache/js/`) at 5 MiB, and deducts the 1 MiB Wasm cache allocation from the default HTTP cache budget (`kNonHttpReserveBytes` increases from 12 MiB to 13 MiB). Hardcodes the 1 MiB Wasm code cache limit in `GeneratedCodeCacheContext::InitializeOnThread` under `BUILDFLAG(IS_COBALT)`, avoiding changes to upstream `content/` interfaces. Bug: 576735653 TAG=agy CONV=eac8a9ab-09f0-4119-b3a7-5d5ace6ed735 (cherry picked from commit 03b767d) --- Manual cherry-pick to staging. The first commit is the bot-style CONFLICTED cherry-pick, and the second resolves the conflicts against current staging: Kept staging's rewritten GeneratedCodeCacheContext::InitializeOnThread (std::make_unique caches, PersistentCache branch, expected_macros.h include) and applied the IS_COBALT kGeneratedWasmCodeCacheBytes size to the staging generated_wasm_code_cache_ construction. In content_constants.h, kept staging's kDevToolsActivePortFileName and appended the Cobalt-only kGeneratedWasmCodeCacheBytes constant. When squash-merging, keep this description as the commit message so the 'Refer to original PR' and 'cherry picked from' lines stay in staging's history. --------- Co-authored-by: Sean Cuff <sacuff@users.noreply.github.com>
…ta and first-launch bytecode caching Refer to original PR: #13558 ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 (cherry picked from commit 7f86976)
… and first-launch bytecode caching
features.{h,cc}: kept only the kCobaltCodeCacheOptimization feature and its
params; dropped kCobaltFlushHttpServerPropertiesOnPause / kCobaltHttpCacheQuota
context from main (not on staging). cobalt_content_browser_client.cc applied
cleanly and keeps the content::kGeneratedWasmCodeCacheBytes term (#13670 is on
the base). Unittest: restored main's 13->18 MiB / 6 MiB expectations (wasm
term present); dropped only the combined kCobaltHttpCacheQuota +
ConfigureHttpCacheMaxSize case since that prerequisite is not on staging.
…ta and first-launch bytecode caching (#14244) Refer to original PR: #13558 ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 (cherry picked from commit 7f86976) --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub> --------- Co-authored-by: Hao <131711973+haozheng-cobalt@users.noreply.github.com> Co-authored-by: Andrew Savage <andrewsavage@google.com>
Caps the WebAssembly compiled code cache (
Code Cache/wasm/) at 1 MiB while leaving the JavaScript compiled code cache (Code Cache/js/) at 5 MiB, and deducts the 1 MiB Wasm cache allocation from the default HTTP cache budget (kNonHttpReserveBytesincreases from 12 MiB to 13 MiB).Hardcodes the 1 MiB Wasm code cache limit in
GeneratedCodeCacheContext::InitializeOnThreadunderBUILDFLAG(IS_COBALT), avoiding changes to upstreamcontent/interfaces.Bug: 576735653
TAG=agy
CONV=eac8a9ab-09f0-4119-b3a7-5d5ace6ed735