Repository navigation
Avoid temporary rectangles when reading intersection ratios (#60312) - #60312
Merged
Merged
Conversation
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134250349. |
javache
approved these changes
Nov 26, 2026
javache
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
) Summary: ## Context IntersectionObserverEntry ratio getters construct two temporary rectangles even though they only need stored widths and heights. This adds allocation overhead when consumers process many intersection entries. ## Changes Calculate target and root ratios directly from native rectangle tuples, retaining zero-dimension handling and upper clamping. Add a saved-entry stability integration case after subsequent scrolling and use the shared target/root ratio-read benchmarks; this diff adds no benchmark code. ## Compatibility Ratios derive from stored native geometry; overriding rectangle getters no longer changes the calculated ratios. Public rectangle getters retain their existing behavior. ## Benchmark results Optimized Fantom (native + Hermes bytecode), headless Linux, same CPU affinity. The benchmark-only baseline and final stack use the same base containing landed scrollMargin support. Values are median CPU time per complete invocation from the current runs; setup/assertions are outside timed work, and scaling cases have 100 measured invocations. These are workload-specific measurements, not isolated profiler timings or app-wide speedups. | Benchmark | Baseline CPU | Current CPU | CPU reduction | | --- | --- | --- | --- | | `Read intersectionRatio 1000 times` | 5.105 ms | 0.152 ms | 97.0% | | `Read rnRootIntersectionRatio 1000 times` | 4.962 ms | 0.150 ms | 97.0% | These measure callback-consumer ratio reads, not notification dispatch. Changelog: [General][Changed] - Reduce IntersectionObserverEntry ratio-access overhead Reviewed By: javache Differential Revision: D134250349
rubennorte
force-pushed
the
export-D134250349
branch
from
November 26, 2026 14:30
36c5b81 to
adb161c
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
) Summary: ## Context IntersectionObserverEntry ratio getters construct two temporary rectangles even though they only need stored widths and heights. This adds allocation overhead when consumers process many intersection entries. ## Changes Calculate target and root ratios directly from native rectangle tuples, retaining zero-dimension handling and upper clamping. Add a saved-entry stability integration case after subsequent scrolling and use the shared target/root ratio-read benchmarks; this diff adds no benchmark code. ## Compatibility Ratios derive from stored native geometry; overriding rectangle getters no longer changes the calculated ratios. Public rectangle getters retain their existing behavior. ## Benchmark results Optimized Fantom (native + Hermes bytecode), headless Linux, same CPU affinity. The benchmark-only baseline and final stack use the same base containing landed scrollMargin support. Values are median CPU time per complete invocation from the current runs; setup/assertions are outside timed work, and scaling cases have 100 measured invocations. These are workload-specific measurements, not isolated profiler timings or app-wide speedups. | Benchmark | Baseline CPU | Current CPU | CPU reduction | | --- | --- | --- | --- | | `Read intersectionRatio 1000 times` | 5.105 ms | 0.152 ms | 97.0% | | `Read rnRootIntersectionRatio 1000 times` | 4.962 ms | 0.150 ms | 97.0% | These measure callback-consumer ratio reads, not notification dispatch. Changelog: [General][Changed] - Reduce IntersectionObserverEntry ratio-access overhead Reviewed By: javache Differential Revision: D134250349
rubennorte
force-pushed
the
export-D134250349
branch
from
November 26, 2026 18:13
adb161c to
65e9c36
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Nov 26, 2026
) Summary: ## Context IntersectionObserverEntry ratio getters construct two temporary rectangles even though they only need stored widths and heights. This adds allocation overhead when consumers process many intersection entries. ## Changes Calculate target and root ratios directly from native rectangle tuples, retaining zero-dimension handling and upper clamping. Add a saved-entry stability integration case after subsequent scrolling and use the shared target/root ratio-read benchmarks; this diff adds no benchmark code. ## Compatibility Ratios derive from stored native geometry; overriding rectangle getters no longer changes the calculated ratios. Public rectangle getters retain their existing behavior. ## Benchmark results Optimized Fantom (native + Hermes bytecode), headless Linux, same CPU affinity. The benchmark-only baseline and final stack use the same base containing landed scrollMargin support. Values are median CPU time per complete invocation from the current runs; setup/assertions are outside timed work, and scaling cases have 100 measured invocations. These are workload-specific measurements, not isolated profiler timings or app-wide speedups. | Benchmark | Baseline CPU | Current CPU | CPU reduction | | --- | --- | --- | --- | | `Read intersectionRatio 1000 times` | 5.105 ms | 0.152 ms | 97.0% | | `Read rnRootIntersectionRatio 1000 times` | 4.962 ms | 0.150 ms | 97.0% | These measure callback-consumer ratio reads, not notification dispatch. Changelog: [General][Changed] - Reduce IntersectionObserverEntry ratio-access overhead Reviewed By: javache Differential Revision: D134250349
rubennorte
force-pushed
the
export-D134250349
branch
from
November 26, 2026 18:44
65e9c36 to
d6dee0c
Compare
) Summary: ## Context IntersectionObserverEntry ratio getters construct two temporary rectangles even though they only need stored widths and heights. This adds allocation overhead when consumers process many intersection entries. ## Changes Calculate target and root ratios directly from native rectangle tuples, retaining zero-dimension handling and upper clamping. Add a saved-entry stability integration case after subsequent scrolling and use the shared target/root ratio-read benchmarks; this diff adds no benchmark code. ## Compatibility Ratios derive from stored native geometry; overriding rectangle getters no longer changes the calculated ratios. Public rectangle getters retain their existing behavior. ## Benchmark results Optimized Fantom (native + Hermes bytecode), headless Linux, same CPU affinity. The benchmark-only baseline and ratio optimization use a base containing landed scrollMargin support. Values are median CPU time per complete invocation from the current runs; setup/assertions are outside timed work, and scaling cases have 100 measured invocations. These are workload-specific measurements, not isolated profiler timings or app-wide speedups. | Benchmark | Baseline CPU | Current CPU | CPU reduction | | --- | --- | --- | --- | | `Read intersectionRatio 1000 times` | 5.105 ms | 0.152 ms | 97.0% | | `Read rnRootIntersectionRatio 1000 times` | 4.962 ms | 0.150 ms | 97.0% | These measure callback-consumer ratio reads, not notification dispatch. Changelog: [General][Changed] - Reduce IntersectionObserverEntry ratio-access overhead Reviewed By: javache Differential Revision: D134250349
rubennorte
force-pushed
the
export-D134250349
branch
from
November 26, 2026 18:47
d6dee0c to
a06cd75
Compare
Collaborator
|
This pull request was successfully merged by @rubennorte in 521d556 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Context
IntersectionObserverEntry ratio getters construct two temporary rectangles even though they only need stored widths and heights. This adds allocation overhead when consumers process many intersection entries.
Changes
Calculate target and root ratios directly from native rectangle tuples, retaining zero-dimension handling and upper clamping. Add a saved-entry stability integration case after subsequent scrolling and use the shared target/root ratio-read benchmarks; this diff adds no benchmark code.
Compatibility
Ratios derive from stored native geometry; overriding rectangle getters no longer changes the calculated ratios. Public rectangle getters retain their existing behavior.
Benchmark results
Optimized Fantom (native + Hermes bytecode), headless Linux, same CPU affinity. The benchmark-only baseline and ratio optimization use a base containing landed scrollMargin support. Values are median CPU time per complete invocation from the current runs; setup/assertions are outside timed work, and scaling cases have 100 measured invocations. These are workload-specific measurements, not isolated profiler timings or app-wide speedups.
Read intersectionRatio 1000 timesRead rnRootIntersectionRatio 1000 timesThese measure callback-consumer ratio reads, not notification dispatch.
Changelog:
[General][Changed] - Reduce IntersectionObserverEntry ratio-access overhead
Reviewed By: javache
Differential Revision: D134250349