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

Optimize storageFind #2057

Merged
merged 4 commits into from
Jul 13, 2021
Merged

Optimize storageFind #2057

merged 4 commits into from
Jul 13, 2021

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Jul 12, 2021

Related #2056 .

fyrchik added 4 commits July 12, 2021 14:14
There is no need in additional allocations.

Signed-off-by: Evgeniy Stratonikov <[email protected]>
This allows to use chain in benchmarks.

Signed-off-by: Evgeniy Stratonikov <[email protected]>
Signed-off-by: Evgeniy Stratonikov <[email protected]>
Because `Map` stores elements in arbitrary order, addition of new
element takes linear time (`Index` iterates over all keys). Thus our
`storageFind` is actually quadratic in time. Optimize this by creating
map from sorted slice.

```
name           old time/op    new time/op    delta
StorageFind-8     157µs ± 2%     112µs ± 1%  -28.60%  (p=0.000 n=10+10)

name           old alloc/op   new alloc/op   delta
StorageFind-8    69.4kB ± 0%    60.5kB ± 0%  -12.90%  (p=0.000 n=9+10)

name           old allocs/op  new allocs/op  delta
StorageFind-8     2.21k ± 0%     2.00k ± 0%   -9.37%  (p=0.000 n=10+7)
```

Signed-off-by: Evgeniy Stratonikov <[email protected]>
@roman-khimov roman-khimov added this to the v0.96.0 milestone Jul 13, 2021
@roman-khimov roman-khimov merged commit 2b7abd2 into master Jul 13, 2021
@roman-khimov roman-khimov deleted the optimize-storage-find branch July 13, 2021 09:51
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.

3 participants