Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typegen): glob for files synchronously for deterministic result #8610

Merged
merged 2 commits into from
Feb 12, 2025

Conversation

sgulseth
Copy link
Member

Description

We were using globby.stream, which gives no guarantees on the order of the files returned by the stream. Instead of relying on the async api here we can use the synchronous api and sort the resulting files to get a more deterministic order as the files are changing.

Alternative to #8598

What to review

Correctness

Testing

I added a test, but I skip it by default as it has to run many iterations to maybe fail

Notes for release

TypeGen: Sort the scanned files to get a more consistent order of the generated types. Note that first time running this after upgrade you might get a new result because of an earlier mismatch

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 11:56am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 11:56am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 11:56am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 12, 2025 11:56am
test-next-studio ⬜️ Ignored (Inspect) Feb 12, 2025 11:56am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Feb 12, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.47% 53779 / 126621
🔵 Statements 42.47% 53779 / 126621
🔵 Functions 47.95% 2772 / 5781
🔵 Branches 78.88% 10316 / 13078
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/codegen/src/typescript/findQueriesInPath.ts 93.33% 75% 100% 93.33% 57-58, 77
Generated in workflow #30238 for commit 45d3320 by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Feb 12, 2025

⚡️ Editor Performance Report

Updated Wed, 12 Feb 2025 11:57:09 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 24.4 efps (41ms) 22.2 efps (45ms) +4ms (+9.8%)
article (body) 71.9 efps (14ms) 72.2 efps (14ms) -0ms (-/-%)
article (string inside object) 28.2 efps (36ms) 23.5 efps (43ms) +7ms (+19.7%)
article (string inside array) 24.4 efps (41ms) 21.7 efps (46ms) +5ms (+12.2%)
recipe (name) 45.5 efps (22ms) 48.8 efps (21ms) -2ms (-6.8%)
recipe (description) 52.6 efps (19ms) 52.6 efps (19ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (6ms) -1ms (-/-%)
synthetic (title) 20.2 efps (50ms) 20.0 efps (50ms) +1ms (+1.0%)
synthetic (string inside object) 20.4 efps (49ms) 21.1 efps (48ms) -2ms (-3.1%)

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) 41ms 47ms 55ms 423ms 436ms 11.7s
article (body) 14ms 16ms 30ms 78ms 254ms 5.7s
article (string inside object) 36ms 39ms 41ms 137ms 118ms 6.6s
article (string inside array) 41ms 43ms 48ms 148ms 136ms 6.8s
recipe (name) 22ms 24ms 26ms 47ms 0ms 7.6s
recipe (description) 19ms 21ms 24ms 61ms 0ms 4.7s
recipe (instructions) 7ms 8ms 9ms 49ms 0ms 3.4s
synthetic (title) 50ms 52ms 56ms 210ms 560ms 12.1s
synthetic (string inside object) 49ms 52ms 76ms 556ms 1274ms 8.6s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 45ms 50ms 87ms 467ms 1083ms 12.8s
article (body) 14ms 17ms 28ms 248ms 368ms 6.0s
article (string inside object) 43ms 44ms 54ms 162ms 322ms 7.7s
article (string inside array) 46ms 51ms 55ms 147ms 382ms 7.8s
recipe (name) 21ms 22ms 25ms 35ms 27ms 7.1s
recipe (description) 19ms 20ms 22ms 44ms 0ms 4.6s
recipe (instructions) 6ms 8ms 9ms 38ms 0ms 3.5s
synthetic (title) 50ms 52ms 58ms 219ms 794ms 12.9s
synthetic (string inside object) 48ms 50ms 55ms 409ms 841ms 7.8s

📚 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.

Copy link
Contributor

github-actions bot commented Feb 12, 2025

Component Testing Report Updated Feb 12, 2025 1:31 PM (UTC)

❌ Failed Tests (4) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 9s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 2m 33s 3 0 3
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 52s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 15s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 7s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 34s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 2m 5s 21 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 13s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ❌ Failed (Inspect) 2m 25s 20 0 1
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@sgulseth sgulseth marked this pull request as ready for review February 12, 2025 11:47
@sgulseth sgulseth requested a review from a team as a code owner February 12, 2025 11:47
@sgulseth sgulseth requested a review from stipsan February 12, 2025 11:47
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.

Awesome!

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.

2 participants