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

[icons][docs] Index search synchronously #44001

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions docs/data/material/components/material-icons/SearchIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,25 +522,21 @@ const allIconsMap = {};
const allIcons = Object.keys(mui)
.sort()
.map((importName) => {
let theme;
if (importName.includes('Outlined')) {
theme = 'Outlined';
} else if (importName.includes('TwoTone')) {
theme = 'Two tone';
} else if (importName.includes('Rounded')) {
theme = 'Rounded';
} else if (importName.includes('Sharp')) {
theme = 'Sharp';
} else {
theme = 'Filled';
let theme = 'Filled';
let name = importName;

for (const currentTheme of ['Outlined', 'Rounded', 'TwoTone', 'Sharp']) {
if (importName.endsWith(currentTheme)) {
theme = currentTheme === 'TwoTone' ? 'Two tone' : currentTheme;
name = importName.slice(0, -currentTheme.length);
break;
}
}

const name = importName.replace(/(Outlined|TwoTone|Rounded|Sharp)$/, '');
let searchable = name;
if (synonyms[searchable]) {
searchable += ` ${synonyms[searchable]}`;
}
searchIndex.addAsync(importName, searchable);
searchIndex.add(importName, searchable);
Comment on lines -543 to +539
Copy link
Member Author

@oliviertassinari oliviertassinari Oct 5, 2024

Choose a reason for hiding this comment

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

The change that yields this outcome. Raised in nextapps-de/flexsearch#451.

Now, this is strange, what the async call seems to do is only https://github.com/nextapps-de/flexsearch/blob/961c3ae84a87fb3af2a52047fd7c8adc8949b86d/src/async.js#L32. So, I don't really see why 6,000 calls to setTimeout is slower. cc @romgrk if you ever seen stuff like this in the past.

Copy link
Member

@Janpot Janpot Oct 6, 2024

Choose a reason for hiding this comment

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

That whole initialization block becomes about 3 times slower for me now. It's indexing everything synchronously during module evaluation. Perhaps we can defer it as a whole? Trying a few things in #44025.

Copy link
Member Author

@oliviertassinari oliviertassinari Oct 6, 2024

Choose a reason for hiding this comment

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

That whole initialization block becomes about 3 times slower for me now. It's indexing everything synchronously during module evaluation.

@Janpot Ah, ok, this PR description wasn't super clear, I have updated it with what I was measuring. My goal was to show how time to interactive went from 6.2s to 1.9s.

It's indexing everything synchronously during module evaluation. Perhaps we can defer it as a whole? Trying a few things in #44025.

Yeah, this could be even better 👍. Overall, I find it strange that we need 700ms to index 6,000 records. This feels broken. Maybe we need a different search engine too.

Now, it's unclear to me if we need to go as far. I would be curious to merge this, wait for 30 days to see how the field vitals are and see if we need to allocate more time on this problem.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok, this PR description wasn't super clear, I have updated it with what I was measuring. My goal was to show how time to interactive went from 6.2s to 1.9s.

It was clear, I assume it's caused by the event loop being saturated. I just meant that the module evaluation was blocked for longer. It impacts hydration but the page should be visible because SSR.

Overall, I find it strange that we need 700ms to index 6,000 records. This feels broken. Maybe we need a different search engine too.

👍


const icon = {
importName,
Expand Down