Skip to content

[compiler] Add experimental trace-tape runtime and opt-in emission prototype#36303

Open
luckysolanki902 wants to merge 4 commits intofacebook:mainfrom
luckysolanki902:experimental/trace-tape-runtime
Open

[compiler] Add experimental trace-tape runtime and opt-in emission prototype#36303
luckysolanki902 wants to merge 4 commits intofacebook:mainfrom
luckysolanki902:experimental/trace-tape-runtime

Conversation

@luckysolanki902
Copy link
Copy Markdown

@luckysolanki902 luckysolanki902 commented Apr 17, 2026

Summary

  • add an experimental trace-tape runtime API to react-compiler-runtime
  • add runtime tests, benchmark coverage, and README notes for the research surface
  • add an opt-in compiler emission path that attaches Component.__traceTape for a tiny annotated JSX subset
  • add pragma parsing coverage and a compiler snapshot fixture for the new emission path

Why

This prototypes an out-of-the-box execution model experiment: recording a render as branch guards plus dependency-driven patch operations, then replaying stable-path updates without re-running the entire render callback.

The compiler-side change stays intentionally narrow. It only emits a trace-tape companion when both of these are true:

  • the experimental enableEmitTraceTape flag is enabled
  • the function uses 'use trace tape' and matches a tiny pure subset (single return of one JSX element with direct prop-member reads)

That keeps the prototype honest: the PR demonstrates a concrete codegen seam without implying that arbitrary React can already lower into this execution model.

Validation

  • yarn workspace react-compiler-runtime build
  • yarn workspace react-compiler-runtime test
  • yarn workspace react-compiler-runtime benchmark:trace-tape
  • yarn workspace babel-plugin-react-compiler build
  • yarn workspace babel-plugin-react-compiler run jest parseConfigPragma-test.ts
  • yarn workspace babel-plugin-react-compiler run snap -p trace-tape-annotation
  • yarn workspace babel-plugin-react-compiler test

Benchmark

On the included synthetic benchmark of 20,000 stable-path updates:

  • snapshot re-execution: ~71.3ms
  • trace replay: ~32.4ms
  • full renders in trace mode: 1

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 17, 2026

Hi @luckysolanki902!

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!

@luckysolanki902 luckysolanki902 changed the title [compiler-runtime] Add experimental trace-tape render replay prototype [compiler] Add experimental trace-tape runtime and opt-in emission prototype Apr 17, 2026
@meta-cla meta-cla bot added the CLA Signed label Apr 17, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 17, 2026

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant