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

feat: MongoDB batch call speed optimization #922

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

DRK3
Copy link
Collaborator

@DRK3 DRK3 commented Dec 6, 2021

Added an optimization for places that call the store.Batch method using keys that are guaranteed to be new. This optimization speeds up those calls significantly when using MongoDB.

Signed-off-by: Derek Trider Derek.Trider@securekey.com

@codecov
Copy link

codecov bot commented Dec 6, 2021

Codecov Report

Merging #922 (ba6038d) into main (d06b4e6) will increase coverage by 0.05%.
The diff coverage is 91.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
+ Coverage   89.29%   89.35%   +0.05%     
==========================================
  Files         159      159              
  Lines       14541    14565      +24     
==========================================
+ Hits        12985    13014      +29     
+ Misses        954      949       -5     
  Partials      602      602              
Impacted Files Coverage Δ
pkg/store/didanchor/store.go 91.22% <84.21%> (-4.02%) ⬇️
pkg/didanchor/memdidanchor/store.go 100.00% <100.00%> (ø)
pkg/observer/observer.go 82.21% <100.00%> (+0.43%) ⬆️
pkg/store/operation/store.go 93.65% <100.00%> (+0.20%) ⬆️
pkg/store/witness/witness.go 90.90% <100.00%> (+0.10%) ⬆️
...pub/service/inbox/httpsubscriber/httpsubscriber.go 100.00% <0.00%> (+9.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d06b4e6...ba6038d. Read the comment docs.

@@ -70,6 +70,8 @@ func (s *Store) Put(anchorID string, witnesses []*proof.Witness) error {

anchorIDEncoded := base64.RawURLEncoding.EncodeToString([]byte(anchorID))

putOptions := &storage.PutOptions{IsNewKey: true}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this here. There will usually only be 2 or 3 items in the batch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It'll still be faster and more efficient to use this flag whenever possible. Is there some reason not to?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it's fine. I didn't notice that a UUID was used as the key.

@DRK3 DRK3 force-pushed the MongoDBBatchOptimization branch 5 times, most recently from 6a8616e to 13ab8ec Compare December 6, 2021 22:10
Added an optimization for places that call the store.Batch method using keys that are guaranteed to be new. This optimization speeds up those calls significantly when using MongoDB.

Signed-off-by: Derek Trider <Derek.Trider@securekey.com>
@DRK3 DRK3 marked this pull request as ready for review December 7, 2021 00:18
@@ -70,6 +70,8 @@ func (s *Store) Put(anchorID string, witnesses []*proof.Witness) error {

anchorIDEncoded := base64.RawURLEncoding.EncodeToString([]byte(anchorID))

putOptions := &storage.PutOptions{IsNewKey: true}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it's fine. I didn't notice that a UUID was used as the key.

@DRK3 DRK3 merged commit 1ece896 into trustbloc:main Dec 7, 2021
vkubiv pushed a commit to vkubiv/orb that referenced this pull request Dec 7, 2021
feat: MongoDB batch call speed optimization
Signed-off-by: Volodymyr Kubiv <volodymyr.kubiv@euristiq.com>
vkubiv pushed a commit to vkubiv/orb that referenced this pull request Dec 7, 2021
feat: MongoDB batch call speed optimization
Signed-off-by: Volodymyr Kubiv <volodymyr.kubiv@euristiq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants