Skip to content

feat(yoga): Add cache miss tracking to LayoutData for hit rate metrics - #55824

Closed
zubeyralmaho wants to merge 1 commit into
react:mainfrom
zubeyralmaho:feat/yoga-cache-miss-metrics
Closed

feat(yoga): Add cache miss tracking to LayoutData for hit rate metrics#55824
zubeyralmaho wants to merge 1 commit into
react:mainfrom
zubeyralmaho:feat/yoga-cache-miss-metrics

Conversation

@zubeyralmaho

@zubeyralmaho zubeyralmaho commented Mar 2, 2026

Copy link
Copy Markdown

PR: feat(yoga): Add cache miss tracking to LayoutData for hit rate metrics

Summary

Add layoutCacheMisses and measureCacheMisses fields to Yoga's LayoutData struct to enable cache hit rate calculation in layout performance analysis.

Currently, Yoga tracks cache hits (cachedLayouts, cachedMeasures) but not cache misses. This makes it impossible to calculate cache efficiency metrics like hit rate percentage.

With this change, consumers of the LayoutPassEnd event can now compute:

float layoutHitRate = (float)cachedLayouts / (cachedLayouts + layoutCacheMisses);
float measureHitRate = (float)cachedMeasures / (cachedMeasures + measureCacheMisses);

This enables better performance profiling and optimization insights for React Native apps.

Changelog: [INTERNAL] [ADDED] - Add cache miss tracking to Yoga LayoutData for hit rate metrics

Test Plan

  • Built Yoga library successfully with cmake and make
  • Verified first layout produces cache misses (2 misses for root + child nodes)
  • Verified second layout with same dimensions produces cache hits (1 hit)
  • Verified cache hit rate is calculable (100% on second pass with same dimensions)
Testing cache hit/miss metrics...
After first layout:
  cachedLayouts: 0
  layoutCacheMisses: 2
  ✓ First layout has expected cache misses

After second layout (same dimensions):
  cachedLayouts: 1
  layoutCacheMisses: 0
  ✓ Second layout has expected cache hits

Layout Cache Hit Rate: 100%
✅ All cache metrics tests passed!

Impact

  • No breaking changes
  • Backward compatible (new fields default to 0)
  • Minimal performance overhead (single integer increment per layout operation)

@meta-cla

meta-cla Bot commented Mar 2, 2026

Copy link
Copy Markdown

Hi @zubeyralmaho!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Mar 2, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 2, 2026
## Summary
Add layoutCacheMisses and measureCacheMisses fields to LayoutData struct
to enable cache hit rate calculation in layout performance analysis.

## Motivation
Currently Yoga tracks cache hits but not misses, making it impossible
to calculate cache efficiency. This change enables:

  hitRate = cachedLayouts / (cachedLayouts + layoutCacheMisses)

## Changes
- Added layoutCacheMisses and measureCacheMisses to LayoutData struct
- Track cache misses in calculateLayoutInternal() when cache lookup fails

## Test Plan
- Built Yoga library successfully
- Verified first layout has cache misses
- Verified second layout (same dimensions) has cache hits
- Cache hit rate is now calculable
@zubeyralmaho
zubeyralmaho force-pushed the feat/yoga-cache-miss-metrics branch from c9fe00f to fe37280 Compare March 2, 2026 07:33
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 2, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 30, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

1 similar comment
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants