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

db: improve performance of VersionManager.Copy by 40% just by providing size hint #11454

Closed
4 tasks done
odeke-em opened this issue Mar 25, 2022 · 0 comments
Closed
4 tasks done
Assignees
Labels
T: Performance Performance improvements

Comments

@odeke-em
Copy link
Collaborator

Summary of Bug

If we examine the code in here

func (vm *VersionManager) Copy() *VersionManager {
vmap := make(map[uint64]struct{})
for ver, _ := range vm.versions {
vmap[ver] = struct{}{}
}
return &VersionManager{versions: vmap, initial: vm.initial, last: vm.last}
}
we can see this interesting piece of code
vmap := make(map[uint64]struct{})

That code should use a hint to make it even faster and here are some exhibits https://dashboard.bencher.orijtech.com/benchmark/213d0080ec47409d95c512bca4a8a27e with improvements in every dimension

mapscapacity-allocop
mapscapacity-allocsop
mapscapacity-time


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Performance Performance improvements
Projects
None yet
Development

No branches or pull requests

3 participants