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

[DAT-63] feat: Improve search performances #8

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Conversation

paultranvan
Copy link
Contributor

@paultranvan paultranvan commented Oct 30, 2024

Since #6, we noticed a severe performance degradation when performing search.

We measured the following:

  • Flexsearch search: <ms
  • Query cozy-client store to get file paths: ~120ms for 60 files.
  • Results normalization: ~3ms

We used to make multiple getById queries to get file path, each of them taking few ms. So we tried to use a getByIds instead, and got ~70ms per query, which is better, but still slow.
Then, we tried the following:

  const allFiles = client.getCollectionFromState(FILES_DOCTYPE) as IOCozyFile[]
  const dirs = allFiles.filter(file => file.type === TYPE_DIRECTORY)
  return dirs.filter(dir => dirIds.includes(dir._id))

This takes 2ms.

We should eventually investigate why the store queries are so slow, but for now let's use this trick.

⚠️ This is unrelated to this PR, but we also noticed a dramatic performance drop when using Firefox: the postmessage communication takes ~400ms for 100 search results vs 02.ms with Chrome

Since #6,
we noticed a severe performance degradation when performing search.

We measured the following:
- Flexsearch search: <ms
- Query cozy-client store to get file paths: ~120ms for 60 files.
- Results normalization: ~3ms

We used to make multiple `getById` queries to get file path, each of
them taking few ms. So we tried to use a `getByIds` instead, and got
~70ms per query, which is better, but still slow.
Then, we tried the following:
```
  const allFiles = client.getCollectionFromState(FILES_DOCTYPE) as IOCozyFile[]
  const dirs = allFiles.filter(file => file.type === TYPE_DIRECTORY)
  return dirs.filter(dir => dirIds.includes(dir._id))
```

This takes 2ms.

We should eventually investigate why the store queries are so slow, but
for now let's use this trick.
@paultranvan paultranvan requested a review from Ldoppea October 30, 2024 13:41
@paultranvan paultranvan merged commit d68e340 into main Oct 30, 2024
1 check passed
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