Skip to content

LOW: Implement filtering for search pages. #37619

@TMisiukiewicz

Description

@TMisiukiewicz

Problem

Based on our measurements in high-traffic accounts, the search page takes an average of 4100ms to re-render on every keystroke. This is a problem because the user will notice a significant lag between changing their search term and the results list updating.
The root cause of this problem is getSearchText, which is called for every keystroke and is inefficient because it reconstructs all the options in the results list using createOption over and over.

Solution

Let's speed up getSearchText by refactoring it such that, instead of re-generating all the result options every time the search terms change, we just generate the options once and filter them based on the current search term.
To achieve this, we recommend using a rank-value sorting, where a higher number means it will appear higher in the list:

  • Acronym - item’s acronym is the given value
  • Contains - item contains the given value
  • Word starts with - if one of the item’s words starts with the given value
  • Starts with - if the item starts with the given value
  • Equals - case-insensitive equality
  • Case sensitive - case-sensitive equality

Note that this will maintain the current search result ordering, just implement it in a different way. By making this change, we can improve the following metrics:

  • open_search → Before: ~5900ms → After: ~4900ms (~1000ms improvement)
  • load_search_options → Before: ~4100ms → After: ~3200ms (~900ms improvement)
  • search query changed after initial load → Before: 4100ms → After: 350ms (~12x improvement)

We can apply this technique everywhere in the app where we use a search bar to filter option results.

Issue OwnerCurrent Issue Owner: @stephanieelliott

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionEngineeringNewFeatureSomething to build that is a new item.WeeklyKSv2

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions