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: simplify search strategy configuration #7765

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Nov 6, 2024

Description

The search strategy was previously selected using the search.enableLegacySearch boolean, which became confusing after we reverted the default behaviour. Developers had to explicitly set search.enableLegacySearch to false in order to enable the Text Search API strategy.

This change deprecates search.enableLegacySearch in favour of the search.strategy union, which is clearer and more flexible.

The current options are:

  • "groqLegacy": Legacy search strategy (the current default).
  • "textSearch": Search using the Text Search API.

In the near future, we will add a new option, allowing developers to test the new GROQ search strategy.

If the project already sets search.enableLegacySearch to false, this will automatically be mapped to the "textSearch" strategy. If the project uses both search.enableLegacySearch and search.strategy, search.strategy will take precedence.

What to review

  • Are we happy with the new approach to configuring this option? Keep in mind that most developers won't need to use this option; its purpose is mostly to allow developers to test changes to the search strategy.
  • Are we happy with the deprecation, and future removal of, the search.enableLegacySearch configuration option?
  • Are we happy with the names "groqLegacy" and "textSearch"?

Testing

  • Updated affected tests.
  • Added unit tests for configuration resolution.
  • Setting search.enableLegacySearch to false automatically sets search.strategy to "textSearch".
  • Setting search.enableLegacySearch to true automatically sets search.strategy to "groqLegacy".
  • When setting both search.enableLegacySearch and search.strategy, search.strategy takes precedence.
  • When plugins and workspaces both set these options, the workspace configuration takes precedence.
  • The correct search strategy is used (the behaviour is the same as before).
    • When using "groqLegacy", searches result in HTTP requests to data/query.
    • When using "textSearch", searches result in HTTP requests to data/textsearch.

Notes for release

If you aren't using the Text Search API in your Studio—or don't know what it is—you can ignore this.

The search.enableLegacySearch configuration option has been deprecated and will be removed in a future release. You can still set search.enableLegacySearch to false to enable the Text Search API in your Studio for now, but we encourage you to instead set search.strategy to "textSearch". We've made this change so that it's easier to test different search strategies in the future.

Sanity config (sanity.config.ts/js) migration

search: {
-  enableLegacySearch: false,
+  strategy: 'textSearch',
},

Copy link

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

@juice49 juice49 force-pushed the feat/sapp-30/search-strategy-configuration branch from d221034 to bd8c0b7 Compare November 6, 2024 16:22
@juice49 juice49 changed the title feat: migrate from search.enableLegacySearch option to clearer and more flexible search.strategy option feat: migrate from search.enableLegacySearch option to clearer and more flexible search.strategy option Nov 6, 2024
@juice49 juice49 force-pushed the feat/sapp-30/search-strategy-configuration branch from bd8c0b7 to 3341b00 Compare November 6, 2024 16:44
@juice49 juice49 force-pushed the feat/sapp-30/search-strategy-configuration branch from 3341b00 to ff1dd50 Compare November 6, 2024 17:06
Copy link
Contributor

github-actions bot commented Nov 6, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Nov 6, 2024

Component Testing Report Updated Nov 7, 2024 4:11 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 46s 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) 18s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 33s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 47s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 48s 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) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 19s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 37s 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 6, 2024

⚡️ Editor Performance Report

Updated Thu, 07 Nov 2024 16:14:00 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 17.2 efps (58ms) 16.4 efps (61ms) +3ms (+5.2%)
article (body) 56.3 efps (18ms) 53.5 efps (19ms) +1ms (+5.4%)
article (string inside object) 17.2 efps (58ms) 16.7 efps (60ms) +2ms (+3.4%)
article (string inside array) 14.4 efps (70ms) 14.9 efps (67ms) -3ms (-3.6%)
recipe (name) 28.6 efps (35ms) 29.4 efps (34ms) -1ms (-2.9%)
recipe (description) 33.3 efps (30ms) 33.3 efps (30ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (7ms) +0ms (-/-%)
synthetic (title) 13.3 efps (75ms) 14.3 efps (70ms) -5ms (-6.7%)
synthetic (string inside object) 14.5 efps (69ms) 14.7 efps (68ms) -1ms (-1.4%)

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) 58ms 64ms 88ms 146ms 372ms 12.9s
article (body) 18ms 23ms 37ms 293ms 491ms 6.4s
article (string inside object) 58ms 64ms 71ms 96ms 372ms 8.7s
article (string inside array) 70ms 73ms 75ms 319ms 1116ms 9.8s
recipe (name) 35ms 38ms 45ms 65ms 9ms 9.3s
recipe (description) 30ms 31ms 33ms 84ms 12ms 5.9s
recipe (instructions) 7ms 9ms 9ms 15ms 26ms 3.4s
synthetic (title) 75ms 82ms 89ms 506ms 2194ms 17.3s
synthetic (string inside object) 69ms 74ms 83ms 578ms 1785ms 10.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 61ms 64ms 70ms 253ms 506ms 14.4s
article (body) 19ms 22ms 54ms 222ms 384ms 6.3s
article (string inside object) 60ms 65ms 72ms 316ms 512ms 9.1s
article (string inside array) 67ms 75ms 83ms 237ms 857ms 9.4s
recipe (name) 34ms 37ms 70ms 78ms 1ms 9.6s
recipe (description) 30ms 32ms 47ms 91ms 24ms 6.0s
recipe (instructions) 7ms 9ms 10ms 35ms 0ms 3.4s
synthetic (title) 70ms 78ms 90ms 418ms 1587ms 15.8s
synthetic (string inside object) 68ms 72ms 84ms 514ms 1681ms 10.6s

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

@juice49 juice49 force-pushed the feat/sapp-30/search-strategy-configuration branch from a224c66 to bf7e1a2 Compare November 7, 2024 15:39
The search strategy was previously selected using the
`search.enableLegacySearch` boolean, which became confusing after we
reverted the default behaviour. Developers had to explicitly set
`search.enableLegacySearch` to `false` in order to enable the Text
Search API strategy.

This change deprecates `search.enableLegacySearch` in favour of
the `search.strategy` union, which is clearer and more flexible.

The current options are:

- `"groqLegacy"`: Legacy search strategy (the current default).
- `"textSearch"`: Search using the Text Search API.

In the near future, we will add a new option, allowing developers to
test the new GROQ search strategy.

If the project already sets `search.enableLegacySearch` to `false`,
this will automatically be mapped to the `"textSearch"` strategy.
If the project uses both `search.enableLegacySearch` and
`search.strategy`, `search.strategy` will take precedence.
Copy link
Contributor

@pedrobonamin pedrobonamin left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for adding the tests describing all the scenarios, it makes it very simple to review.

@juice49 juice49 added this pull request to the merge queue Nov 7, 2024
Merged via the queue into next with commit 4d8193f Nov 8, 2024
59 checks passed
@juice49 juice49 deleted the feat/sapp-30/search-strategy-configuration branch November 8, 2024 09:15
bjoerge added a commit that referenced this pull request Nov 8, 2024
* next:
  fix(deps): upgrade `@sanity/ui` to `2.8.22` (#7783)
  fix(deps): Update dev-non-major (#7770)
  fix(deps): update dependency @portabletext/editor to ^1.6.1 (#7778)
  fix(deps): update dependency @sanity/presentation to v1.17.10 (#7767)
  fix(deps): update dependency @sanity/mutate to ^0.10.2 (#7781)
  fix(deps): update dependency @sanity/ui to ^2.8.21 (#7779)
  fix(deps): update dependency @sanity/client to ^6.22.3 (#7766)
  feat: simplify search strategy configuration (#7765)
  chore: update Studio teams in CODEOWNERS (#7780)
  chore(deps): update typescript-tooling (#7762)
  fix(deps): update dependency @portabletext/editor to ^1.5.5 (#7763)
  fix(deps): update dependency react-rx to ^4.1.4 (#7768)
  chore(deps): lock file maintenance (#7757)
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