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: add support for profiling CLI commands through SANITY_DEBUG_PROFILING #8201

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

judofyr
Copy link
Contributor

@judofyr judofyr commented Jan 7, 2025

Description

This adds support for a new environment variable (SANITY_DEBUG_PROFILING=<DIRECTORY>) which runs all the worker commands (schema extract, manifest extract etc) under the V8 profiler and dumps it for further inspection.

What to review

Further testing that it works not only on my machine would be nice.

Testing

I've tested it manually on a real-world Studio by running npm link ../sanity/packages/sanity and invoking the command.

Notes for release

Not required (I think).

@judofyr judofyr self-assigned this Jan 7, 2025
@judofyr judofyr requested a review from a team as a code owner January 7, 2025 11:20
@judofyr judofyr requested review from RitaDias and removed request for a team January 7, 2025 11:20
Copy link

vercel bot commented Jan 7, 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 Jan 7, 2025 11:46am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 11:46am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 11:46am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 11:46am
test-next-studio ⬜️ Ignored (Inspect) Jan 7, 2025 11:46am

Copy link
Contributor

github-actions bot commented Jan 7, 2025

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Component Testing Report Updated Jan 7, 2025 11:48 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 4s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 39s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 51s 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) 14s 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 26s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 39s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 12s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 42s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Jan 7, 2025

⚡️ Editor Performance Report

Updated Tue, 07 Jan 2025 11:50:59 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 21.1 efps (48ms) 26.7 efps (38ms) -10ms (-21.1%)
article (body) 53.2 efps (19ms) 50.3 efps (20ms) +1ms (+5.9%)
article (string inside object) 25.0 efps (40ms) 27.0 efps (37ms) -3ms (-7.5%)
article (string inside array) 22.2 efps (45ms) 24.4 efps (41ms) -4ms (-8.9%)
recipe (name) 43.5 efps (23ms) 52.6 efps (19ms) -4ms (-17.4%)
recipe (description) 50.0 efps (20ms) 62.5 efps (16ms) -4ms (-20.0%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (6ms) +0ms (-/-%)
synthetic (title) 17.9 efps (56ms) 18.9 efps (53ms) -3ms (-5.4%)
synthetic (string inside object) 19.0 efps (53ms) 20.4 efps (49ms) -4ms (-6.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 58ms 86ms 196ms 1021ms 11.5s
article (body) 19ms 21ms 30ms 320ms 420ms 6.1s
article (string inside object) 40ms 42ms 47ms 163ms 168ms 7.1s
article (string inside array) 45ms 47ms 58ms 184ms 480ms 7.6s
recipe (name) 23ms 26ms 29ms 38ms 0ms 7.9s
recipe (description) 20ms 21ms 24ms 38ms 0ms 4.7s
recipe (instructions) 6ms 8ms 9ms 29ms 0ms 3.1s
synthetic (title) 56ms 59ms 64ms 288ms 1234ms 14.3s
synthetic (string inside object) 53ms 56ms 66ms 309ms 1011ms 8.5s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 38ms 41ms 65ms 370ms 926ms 10.9s
article (body) 20ms 23ms 30ms 203ms 300ms 5.8s
article (string inside object) 37ms 39ms 51ms 65ms 273ms 6.6s
article (string inside array) 41ms 43ms 49ms 253ms 326ms 7.0s
recipe (name) 19ms 21ms 28ms 40ms 0ms 6.9s
recipe (description) 16ms 18ms 19ms 36ms 0ms 4.3s
recipe (instructions) 6ms 7ms 8ms 9ms 0ms 3.2s
synthetic (title) 53ms 56ms 81ms 454ms 1196ms 13.3s
synthetic (string inside object) 49ms 51ms 55ms 478ms 533ms 8.0s

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

@RitaDias
Copy link
Contributor

RitaDias commented Jan 8, 2025

I need some clarification on how to test this manually, sorry if this is obvious.
Where should I add SANITY_DEBUG_PROFILING=<DIRECTORY> (with a specific path I take it?) in the .env of the studio I'm using? What am I expected to find (I'm assuming a file with profiling info in the specific path provided)?

Because I did this but I wasn't able to find the cpu profile file, so I'm guess I did something wrong 😅

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