Skip to content

Reuse IntersectionObserver target ancestry (#60311) - #60311

Open
rubennorte wants to merge 1 commit into
react:mainfrom
rubennorte:export-D134250309
Open

rubennorte wants to merge 1 commit into
react:mainfrom
rubennorte:export-D134250309

Conversation

@rubennorte

@rubennorte rubennorte commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary:

Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

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
Scroll 100 targets, depth 40, 1 thresholds, implicit root 38.032 ms 38.851 ms -2.2% (within noise)
Scroll 100 targets, depth 40, 1 thresholds, explicit root 46.293 ms 40.505 ms 12.5%

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309

@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 Nov 26, 2026
@meta-codesync

meta-codesync Bot commented Nov 26, 2026

Copy link
Copy Markdown

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134250309.

@javache javache 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.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot changed the title Reuse IntersectionObserver target ancestry Reuse IntersectionObserver target ancestry (#60311) Nov 26, 2026
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 26, 2026
Summary:

## Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

## Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

## 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 |
| --- | --- | --- | --- |
| `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | 38.851 ms | -2.2% (within noise) |
| `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | 40.505 ms | 12.5% |

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 26, 2026
Summary:

## Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

## Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

## 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 |
| --- | --- | --- | --- |
| `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | 38.851 ms | -2.2% (within noise) |
| `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | 40.505 ms | 12.5% |

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 26, 2026
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 26, 2026
Summary:

## Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

## Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

## 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 |
| --- | --- | --- | --- |
| `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | 38.851 ms | -2.2% (within noise) |
| `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | 40.505 ms | 12.5% |

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 26, 2026
Summary:

## Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

## Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

## 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 |
| --- | --- | --- | --- |
| `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | 38.851 ms | -2.2% (within noise) |
| `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | 40.505 ms | 12.5% |

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309
Summary:

## Context

Explicit-root intersection updates resolve target-to-root ancestry even after resolving the target-to-surface path. This repeats allocations, parent-family locking, and sibling searches. Implicit roots also copy an ancestor list that can be reused directly.

## Changes

Derive the explicit-root path from the already resolved target ancestry after verifying root membership, and pass the existing list directly for implicit roots. Preserve clipping and detached/non-ancestor behavior. Add a public root-membership integration case and evaluate deep implicit/explicit roots using the shared benchmark-only baseline; this diff adds no benchmark code.

## 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 |
| --- | --- | --- | --- |
| `Scroll 100 targets, depth 40, 1 thresholds, implicit root` | 38.032 ms | 38.851 ms | -2.2% (within noise) |
| `Scroll 100 targets, depth 40, 1 thresholds, explicit root` | 46.293 ms | 40.505 ms | 12.5% |

The ancestry cases use one threshold and emit no callbacks during timed updates. Times include mounting; the small implicit-root difference is within run-to-run variation. Clipping and scrollMargin semantics are unchanged.

Changelog:
[General][Changed] - Reduce IntersectionObserver ancestor traversal overhead

Reviewed By: javache

Differential Revision: D134250309

This branch has not been deployed

No deployments
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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants