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

fix(core): explicitly pass randomKey(12) as the PTE keyGenerator #7759

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

christianhg
Copy link
Contributor

In an effort to make @portabletext/editor become more stand-alone, I'm looking into removing the few @sanity/* dependencies that it has. Here, @sanity/util is a low-hanging fruit.

If the keyGenerator prop isn't passed, the PortableTextEditor will use randomKey(12) from @sanity/util. However, passing this key generator explictly from the PortableTextInput removes this implicit dependency. Now, the Studio keeps getting the same type of random keys and @portabletext/editor is free to remove the @sanity/util dependency and just copy/paste the source code of randomKey or use another default key generator.

In an effort to make `@portabletext/editor` become more stand-alone, I'm
looking into removing the few `@sanity/*` dependencies that it has. Here,
`@sanity/util` is a low-hanging fruit.

If the `keyGenerator` prop isn't passed, the `PortableTextEditor` will use
`randomKey(12)` from `@sanity/util`. However, passing this key generator
explicitly from the `PortableTextInput` removes this implicit dependency. Now,
the Studio keeps getting the same type of random keys and
`@portabletext/editor` is free to remove the `@sanity/util` dependency and
just copy/paste the source code of `randomKey` or use another default key
generator.
Copy link

vercel bot commented Nov 5, 2024

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 Nov 5, 2024 2:36pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 2:36pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 2:36pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 2:36pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 2:36pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Nov 5, 2024 2:36pm

Copy link
Contributor

github-actions bot commented Nov 5, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Nov 5, 2024

Component Testing Report Updated Nov 5, 2024 2:30 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 47s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 39s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 5s 2 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 47s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 50s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 19s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 29s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 38s 12 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 Nov 5, 2024

⚡️ Editor Performance Report

Updated Tue, 05 Nov 2024 14:32:36 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 17.9 efps (56ms) 17.5 efps (57ms) +1ms (+1.8%)
article (body) 63.9 efps (16ms) 59.9 efps (17ms) +1ms (+6.7%)
article (string inside object) 18.5 efps (54ms) 18.7 efps (54ms) -1ms (-0.9%)
article (string inside array) 16.4 efps (61ms) 15.9 efps (63ms) +2ms (+3.3%)
recipe (name) 29.4 efps (34ms) 29.4 efps (34ms) +0ms (-/-%)
recipe (description) 32.3 efps (31ms) 33.3 efps (30ms) -1ms (-3.2%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (6ms) +0ms (-/-%)
synthetic (title) 14.7 efps (68ms) 14.5 efps (69ms) +1ms (+1.5%)
synthetic (string inside object) 14.5 efps (69ms) 15.2 efps (66ms) -3ms (-4.3%)

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) 56ms 58ms 90ms 297ms 558ms 12.6s
article (body) 16ms 18ms 27ms 84ms 116ms 5.1s
article (string inside object) 54ms 62ms 72ms 158ms 489ms 8.8s
article (string inside array) 61ms 64ms 85ms 221ms 949ms 9.4s
recipe (name) 34ms 38ms 54ms 78ms 18ms 8.6s
recipe (description) 31ms 34ms 49ms 65ms 23ms 6.3s
recipe (instructions) 6ms 8ms 10ms 18ms 0ms 3.3s
synthetic (title) 68ms 71ms 80ms 338ms 1527ms 31.5s
synthetic (string inside object) 69ms 72ms 80ms 520ms 1471ms 10.1s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 57ms 62ms 77ms 209ms 426ms 12.5s
article (body) 17ms 19ms 21ms 180ms 285ms 5.5s
article (string inside object) 54ms 59ms 68ms 141ms 546ms 8.8s
article (string inside array) 63ms 72ms 85ms 209ms 1035ms 9.5s
recipe (name) 34ms 38ms 52ms 84ms 2ms 8.6s
recipe (description) 30ms 32ms 38ms 79ms 12ms 6.3s
recipe (instructions) 6ms 8ms 9ms 13ms 0ms 3.2s
synthetic (title) 69ms 78ms 86ms 600ms 2224ms 15.6s
synthetic (string inside object) 66ms 71ms 99ms 478ms 1884ms 10.3s

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

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Nice, LGTM

@christianhg christianhg added this pull request to the merge queue Nov 6, 2024
Merged via the queue into next with commit 0005825 Nov 6, 2024
67 checks passed
@christianhg christianhg deleted the fix-core-pass-key-generator-to-pte branch November 6, 2024 15:55
bjoerge added a commit that referenced this pull request Nov 6, 2024
* next:
  feat(codegen): fix literal function arguments and add default values
  feat(codegen): add support for export all
  test(internal/cli): migrate internal cli tests to vitest and remove jest (#7745)
  fix(core): explicitly pass `randomKey(12)` as the PTE `keyGenerator` (#7759)
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