Skip to content

metrics: Enable font and glyph cache memory metrics in Cobalt#9127

Merged
Awallky merged 7 commits intoyoutube:mainfrom
Awallky:add-font-based-metrics
Feb 26, 2026
Merged

metrics: Enable font and glyph cache memory metrics in Cobalt#9127
Awallky merged 7 commits intoyoutube:mainfrom
Awallky:add-font-based-metrics

Conversation

@Awallky
Copy link
Contributor

@Awallky Awallky commented Feb 18, 2026

This change enables the reporting of font-related memory usage metrics to UMA, which were previously defined in the engine but not collected.

  • Initialize the memory instrumentation client in the Cobalt browser process to enable process-level allocator dumps.
  • Update CobaltMetricsServiceClient to explicitly extract and record Skia (sk_glyph_cache) and Blink (font_caches/shape_caches) allocator dumps.
  • Add new font cache metrics to the memory histograms allowlist.
  • Add a new browsertest (font_metrics_browsertest) to verify that the new histograms are correctly populated on a running device.
  • Add documentation for the identified font metrics in cobalt/docs/.

These metrics provide visibility into the memory footprint of character rasterization and text shaping caches, aiding in identifying font-related memory regressions and optimizing resource usage.

Bug: 483758673

@Awallky Awallky requested a review from a team as a code owner February 18, 2026 01:10
@github-actions
Copy link
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Enable font and glyph cache memory metrics

Initialize the memory instrumentation client in the browser process
to enable process-level allocator dumps. Update the metrics service
client to explicitly extract and record Skia (sk_glyph_cache) and
Blink (font_caches/shape_caches) allocator dumps. Add new font
cache metrics to the memory histograms allowlist and a browsertest
to verify their population. Also, add documentation for the new
metrics.

These changes provide visibility into the memory footprint of
character rasterization and text shaping caches, aiding in
identifying font-related memory regressions and optimizing
resource usage.

Bug: 483758673

💡 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

Copy link
Contributor

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

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 successfully enables font and glyph cache memory metrics, providing valuable insights into memory usage. The changes are well-structured, including the necessary initialization, metric collection logic, a new browser test, and documentation.

I've provided a few suggestions to improve the precision of the new metrics, enhance test coverage, and ensure the documentation is consistent with the implementation. Overall, this is a solid contribution.

@Awallky Awallky requested a review from sherryzy February 18, 2026 21:46
Copy link
Contributor

@sherryzy sherryzy left a comment

Choose a reason for hiding this comment

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

Overall looks good.

@Awallky Awallky added cp-26.android Cherry Pick to the 26.android branch cp-26.eap Cherry pick to 26.eap branch labels Feb 24, 2026
@Awallky Awallky force-pushed the add-font-based-metrics branch 2 times, most recently from 1a49c38 to 5e4032d Compare February 24, 2026 21:11
@Awallky Awallky enabled auto-merge (squash) February 25, 2026 00:35
@Awallky Awallky force-pushed the add-font-based-metrics branch from 62cc58f to 9a784b0 Compare February 25, 2026 02:57
This change enables the reporting of font-related memory usage metrics
to UMA, which were previously defined in the engine but not collected.

- Initialize the memory instrumentation client in the Cobalt browser
  process to enable process-level allocator dumps.
- Update CobaltMetricsServiceClient to explicitly extract and record
  Skia (sk_glyph_cache) and Blink (font_caches/shape_caches) allocator
  dumps.
- Add new font cache metrics to the memory histograms allowlist.
- Add a new browsertest (font_metrics_browsertest) to verify that the
  new histograms are correctly populated on a running device.
- Add documentation for the identified font metrics in cobalt/docs/.

These metrics provide visibility into the memory footprint of character
rasterization and text shaping caches, aiding in identifying font-related
memory regressions and optimizing resource usage.

Bug: None
When requesting a SUMMARY_ONLY memory dump, providing an empty list of
allocator names results in no Chrome-level allocator metrics being
returned. Conversely, providing a non-empty list acts as a whitelist,
omitting any allocators not in the list.

Explicitly request 'malloc' along with the new font and glyph cache
allocators to ensure comprehensive memory reporting remains intact.

Verified with FontMetricsBrowserTest on Android.
- Optimize RecordMemoryMetrics by moving process_name constant outside the loop.
- Improve precision of Skia and font cache reporting by switching from MB to KB.
- Fix a fatal crash on Android during startup by ensuring idempotent and
  thread-safe memory instrumentation client registration.
- Update documentation and add unit/browser test expectations to verify
  the new granular font memory histograms.

Bug: None
@Awallky Awallky force-pushed the add-font-based-metrics branch from 16bd717 to b55d2f8 Compare February 25, 2026 18:37
@Awallky Awallky merged commit 9769f6a into youtube:main Feb 26, 2026
609 of 612 checks passed
cobalt-github-releaser-bot pushed a commit that referenced this pull request Feb 26, 2026
This change enables the reporting of font-related memory usage metrics
to UMA, which were previously defined in the engine but not collected.

- Initialize the memory instrumentation client in the Cobalt browser
process to enable process-level allocator dumps.
- Update CobaltMetricsServiceClient to explicitly extract and record
Skia (sk_glyph_cache) and Blink (font_caches/shape_caches) allocator
dumps.
- Add new font cache metrics to the memory histograms allowlist.
- Add a new browsertest (font_metrics_browsertest) to verify that the
new histograms are correctly populated on a running device.
- Add documentation for the identified font metrics in cobalt/docs/.

These metrics provide visibility into the memory footprint of character
rasterization and text shaping caches, aiding in identifying
font-related memory regressions and optimizing resource usage.

Bug: 483758673
(cherry picked from commit 9769f6a)
cobalt-github-releaser-bot pushed a commit that referenced this pull request Feb 26, 2026
This change enables the reporting of font-related memory usage metrics
to UMA, which were previously defined in the engine but not collected.

- Initialize the memory instrumentation client in the Cobalt browser
process to enable process-level allocator dumps.
- Update CobaltMetricsServiceClient to explicitly extract and record
Skia (sk_glyph_cache) and Blink (font_caches/shape_caches) allocator
dumps.
- Add new font cache metrics to the memory histograms allowlist.
- Add a new browsertest (font_metrics_browsertest) to verify that the
new histograms are correctly populated on a running device.
- Add documentation for the identified font metrics in cobalt/docs/.

These metrics provide visibility into the memory footprint of character
rasterization and text shaping caches, aiding in identifying
font-related memory regressions and optimizing resource usage.

Bug: 483758673
(cherry picked from commit 9769f6a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp-26.android Cherry Pick to the 26.android branch cp-26.eap Cherry pick to 26.eap branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants