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

[Storage] Refactor badger cache and all the client code to use generics #4565

Merged
merged 13 commits into from
Jul 27, 2023

Conversation

nozim
Copy link
Contributor

@nozim nozim commented Jul 16, 2023

Re: #3932

@nozim nozim changed the title Refactor badger cache and all the client code to use generics [Storage] Refactor badger cache and all the client code to use generics Jul 16, 2023
@Kay-Zee
Copy link
Member

Kay-Zee commented Jul 20, 2023

Thanks for the PR @nozim, I've gone ahead and kicked-off the CI for the branch, and will try to have someone look over the PR soon.

In the mean time, i had to update the branch with latest master to update a dependency that was causing problems for CI, and that seems to have broken tidy.

storage/badger/cache.go Outdated Show resolved Hide resolved
@durkmurder
Copy link
Member

Looks good, did you try measuring performance impact of usings generics instead of interface{} ? We still haven't reached consensus on this topic inside the team.

I would be interested to see at least synthetic benchmarks so we could compare old implementation vs new. Running localnet benchmark should also give some insights. Ideally I would like to see both.

@nozim
Copy link
Contributor Author

nozim commented Jul 23, 2023

@durkmurder good question, will do a small benchmark :)

@nozim
Copy link
Contributor Author

nozim commented Jul 24, 2023

Added small example comparing to interface implementation. @durkmurder fyi :)

This is one of results:

goos: darwin
goarch: amd64
pkg: github.com/onflow/flow-go/storage/badger
cpu: VirtualApple @ 2.50GHz
BenchmarkInterface-8   	 1676054	       694.5 ns/op
BenchmarkGenerics-8    	 2030983	       588.9 ns/op
PASS
ok  	github.com/onflow/flow-go/storage/badger	11.798s

@nozim nozim requested a review from durkmurder July 24, 2023 12:45
@durkmurder
Copy link
Member

durkmurder commented Jul 25, 2023

@nozim Thank you, this is good to go. Can you remove those benchmarks and run lint and tidy?

FYI, you can try passing actual type instead of any and it will be even faster, it's very recognizable if you move RandomBytes outside the loop.

I will approve this after you cleanup it.
Good job!

@durkmurder
Copy link
Member

@nozim just to make it clear, we don't want to merge the benchmark(and iface cache implementation) in master since we don't plan to use previous cache implementation.

@nozim
Copy link
Contributor Author

nozim commented Jul 25, 2023

@durkmurder yes, totally makes sense. Will clean it up as well ;)

@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2023

Codecov Report

Merging #4565 (9d68658) into master (2528190) will decrease coverage by 4.52%.
Report is 323 commits behind head on master.
The diff coverage is 56.36%.

@@            Coverage Diff             @@
##           master    #4565      +/-   ##
==========================================
- Coverage   56.25%   51.73%   -4.52%     
==========================================
  Files         653      734      +81     
  Lines       64699    66142    +1443     
==========================================
- Hits        36396    34219    -2177     
- Misses      25362    29295    +3933     
+ Partials     2941     2628     -313     
Flag Coverage Δ
unittests 51.73% <56.36%> (-4.52%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
cmd/scaffold.go 14.83% <0.00%> (+0.06%) ⬆️
fvm/environment/env.go 100.00% <ø> (ø)
model/flow/identifierList.go 22.36% <0.00%> (+0.84%) ⬆️
model/verification/chunkDataPackRequest.go 43.75% <0.00%> (-6.25%) ⬇️
module/component/component.go 89.92% <ø> (ø)
module/metrics/access.go 0.00% <0.00%> (ø)
module/metrics/herocache.go 0.00% <0.00%> (ø)
module/metrics/network.go 0.00% <0.00%> (ø)
module/metrics/noop.go 0.00% <0.00%> (ø)
module/metrics/observer.go 0.00% <ø> (ø)
... and 61 more

... and 412 files with indirect coverage changes

Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up @nozim! added a few small stylistic comments, but looks good.

storage/badger/cluster_payloads.go Outdated Show resolved Hide resolved
storage/badger/qcs.go Outdated Show resolved Hide resolved
storage/badger/generic_bench.txt Outdated Show resolved Hide resolved
@nozim
Copy link
Contributor Author

nozim commented Jul 26, 2023

@peterargue thanks for review, will address all of the notes )

@nozim nozim requested a review from peterargue July 26, 2023 11:52
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

👍

@durkmurder
Copy link
Member

@nozim can you fix last lint errors so I can approve? We can merge right after

Copy link
Member

@durkmurder durkmurder left a comment

Choose a reason for hiding this comment

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

🚢

@nozim
Copy link
Contributor Author

nozim commented Jul 27, 2023

seems like a glitch in engine unit test?

@durkmurder durkmurder merged commit 3f3da35 into onflow:master Jul 27, 2023
@nozim nozim mentioned this pull request Aug 8, 2023
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.

5 participants