Skip to content

Conversation

@judofyr
Copy link
Contributor

@judofyr judofyr commented Nov 24, 2025

Description

This makes sure that the same field/type definition always ends up becoming the exact same field/type object, making it possible to use === to compare them. In general, this should reduce the memory usage for customers who are reusing the same field multiple places.

This also enables us to later optimize this scenario when serializing as well.

(Note that this PR doesn't actually depend on #11224, but it was easier for me to have a full stack. If this gets attention before #11224 I will reorder them.)

What to review

  • Well, do you have knowledge of places where we might depend on the compiled field/type?

Testing

  • I've tested the test-studio locally, but other than that I depend on the existing tests.

Notes for release

N/A.

@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-building-studio Ready Ready Preview Comment Nov 28, 2025 9:29am
test-studio Ready Ready Preview Comment Nov 28, 2025 9:29am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
e2e-studio Ignored Ignored Nov 28, 2025 9:29am
studio-workshop Ignored Ignored Preview Nov 28, 2025 9:29am
test-next-studio Ignored Ignored Nov 28, 2025 9:29am

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-2f5yp5wsi.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-2f5yp5wsi.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11236-chromium-19759522105 || pr-11236-firefox-19759522105 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11236-chromium-19759522105
  SANITY_E2E_DATASET_FIREFOX=pr-11236-firefox-19759522105

@github-actions
Copy link
Contributor

🧪 E2E Preview environment

Waiting for preview deployment to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@github-actions
Copy link
Contributor

📊 Playwright Test Report

Waiting for E2E tests to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

⚡️ Editor Performance Report

Updated Fri, 28 Nov 2025 09:42:00 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 21.1 efps (48ms) 23.3 efps (43ms) -5ms (-9.5%)
article (body) 36.6 efps (27ms) 33.7 efps (30ms) +2ms (+8.8%)
article (string inside object) 23.8 efps (42ms) 25.3 efps (40ms) -3ms (-6.0%)
article (string inside array) 21.1 efps (48ms) 22.5 efps (45ms) -3ms (-6.3%)
recipe (name) 50.0 efps (20ms) 52.6 efps (19ms) -1ms (-5.0%)
recipe (description) 60.6 efps (17ms) 66.7 efps (15ms) -2ms (-9.1%)
recipe (instructions) 99.9+ efps (8ms) 99.9+ efps (5ms) -3ms (-/-%)
singleString (stringField) 66.7 efps (15ms) 66.7 efps (15ms) +0ms (-/-%)
synthetic (title) 16.9 efps (59ms) 16.8 efps (60ms) +1ms (+0.8%)
synthetic (string inside object) 16.7 efps (60ms) 16.9 efps (59ms) -1ms (-1.7%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 48ms 56ms 90ms 125ms 86ms 11.0s
article (body) 27ms 35ms 84ms 131ms 152ms 6.6s
article (string inside object) 42ms 48ms 62ms 112ms 4ms 6.3s
article (string inside array) 48ms 52ms 72ms 110ms 8ms 6.8s
recipe (name) 20ms 23ms 25ms 35ms 0ms 7.0s
recipe (description) 17ms 20ms 22ms 32ms 0ms 4.2s
recipe (instructions) 8ms 10ms 13ms 21ms 0ms 3.1s
singleString (stringField) 15ms 17ms 20ms 21ms 0ms 7.1s
synthetic (title) 59ms 61ms 69ms 133ms 337ms 14.1s
synthetic (string inside object) 60ms 65ms 119ms 135ms 347ms 7.9s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 43ms 51ms 85ms 102ms 26ms 11.2s
article (body) 30ms 35ms 78ms 128ms 148ms 6.5s
article (string inside object) 40ms 43ms 50ms 137ms 33ms 6.4s
article (string inside array) 45ms 48ms 55ms 125ms 15ms 6.6s
recipe (name) 19ms 21ms 23ms 31ms 0ms 7.3s
recipe (description) 15ms 19ms 22ms 25ms 0ms 4.1s
recipe (instructions) 5ms 9ms 10ms 11ms 0ms 3.0s
singleString (stringField) 15ms 19ms 21ms 25ms 0ms 6.5s
synthetic (title) 60ms 63ms 115ms 158ms 421ms 16.0s
synthetic (string inside object) 59ms 64ms 72ms 280ms 648ms 7.9s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.65% 63695 / 142628
🔵 Statements 44.65% 63695 / 142628
🔵 Functions 48.26% 3402 / 7048
🔵 Branches 79.33% 12921 / 16286
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/schema/src/legacy/Schema.ts 87.31% 92.85% 83.33% 87.31% 30-31, 95-99, 153-154, 170-171, 174-181
packages/@sanity/schema/src/legacy/types/array.ts 95.65% 100% 100% 95.65% 40-41
packages/@sanity/schema/src/legacy/types/crossDatasetReference.ts 89.28% 78.94% 100% 89.28% 48-51, 55-56, 69-72, 118-119
packages/@sanity/schema/src/legacy/types/globalDocumentReference.ts 88% 85% 100% 88% 35-38, 42-43, 56-59, 103-104
packages/@sanity/schema/src/legacy/types/object.ts 79.16% 89.13% 100% 79.16% 79, 83-86, 103-104, 129-134, 149-152, 169-174, 180-185, 198-203, 132-201
packages/@sanity/schema/src/legacy/types/reference.ts 91.75% 90.9% 100% 91.75% 43-44, 57-60, 101-102
packages/@sanity/schema/src/legacy/types/blocks/block.ts 98.42% 100% 100% 98.42% 100-101
packages/@sanity/schema/src/legacy/types/blocks/span.ts 87.95% 100% 83.33% 87.95% 88-97
Generated in workflow #46562 for commit 2a63622 by the Vitest Coverage Report Action

@judofyr judofyr changed the title feat(schema): cache generated field objects feat(schema): cache generated field/type objects Nov 24, 2025
@judofyr judofyr marked this pull request as ready for review November 24, 2025 13:56
@judofyr judofyr requested a review from a team as a code owner November 24, 2025 13:56
@judofyr judofyr requested review from stipsan and removed request for a team November 24, 2025 13:56
@judofyr judofyr force-pushed the cldx-4353/cache-schema-compiler branch from fa80ad9 to 6c30f2b Compare November 24, 2025 15:35
@judofyr judofyr force-pushed the cldx-4337/sanity-validate-metafile branch from 7e30900 to b7b96cd Compare November 24, 2025 15:35
stipsan
stipsan previously approved these changes Nov 25, 2025
Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

I'm wondering if this unlocks better hot module reloading performance with our improved React Compiler coverage.
It might speed up first render too since the schema compiler can skip more work?
Either way great improvement! 💖

Copy link
Contributor Author

judofyr commented Nov 28, 2025

Merge activity

  • Nov 28, 9:22 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 28, 9:24 AM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 28, 9:38 AM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements (PR does not have required approvals).

@judofyr judofyr changed the base branch from cldx-4337/sanity-validate-metafile to graphite-base/11236 November 28, 2025 09:23
@judofyr judofyr changed the base branch from graphite-base/11236 to main November 28, 2025 09:23
@judofyr judofyr dismissed stipsan’s stale review November 28, 2025 09:23

The base branch was changed.

This makes sure that the same field definition always ends up becoming the
exact same field object, making it possible to use `===` to compare them.
@judofyr judofyr force-pushed the cldx-4353/cache-schema-compiler branch from eb204e5 to 2a63622 Compare November 28, 2025 09:23
@judofyr judofyr requested a review from stipsan November 28, 2025 09:25
@judofyr
Copy link
Contributor Author

judofyr commented Nov 28, 2025

Re-review requested only due to the rebasing which happened during merging of parent. No changes.

Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

Let's go 🚢

@judofyr judofyr merged commit 8efdc2b into main Nov 28, 2025
64 checks passed
@judofyr judofyr deleted the cldx-4353/cache-schema-compiler branch November 28, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants