-
Notifications
You must be signed in to change notification settings - Fork 45
Speed up Exchange backup by parallelizing url fetch #1608
Conversation
aade6ed
to
86ba754
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All comments from the onedrive version of this PR also apply.
break | ||
} | ||
// TODO: Tweak sleep times | ||
if i != numberOfRetries-1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: bit of a weird comparison. I'd rather the code make more sense, even if the const seems off by one.
if i != numberOfRetries-1 { | |
if i >= numberOfRetries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think i >= numberOfRetries
will work. I think I'll probably change the code to the following to make it more explicit though:
for i := 1; i <= numberOfRetries; i++ {
...
if i < numberOfRetries {
time.Sleep(time.Duration(3*(i+1)) * time.Second)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, good catch. My brain was backwards. Though, for simplicity, I'd probably go with something like:
for i := 0; i < numberOfRetries; i++ {
response, err = query(...)
if err == nil {
break
}
time.Sleep(duration)
}
The additional conditional and fiddling with the retry count is just code noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for the conditional was so that it would not sleep even with an error in the last run. If we skip that, it sleeps at the end of n-1th
run before exiting out of the loop.
@@ -115,19 +119,20 @@ func (col *Collection) populateByOptionIdentifier( | |||
) { | |||
var ( | |||
errs error | |||
success int | |||
success int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to switch from 32 to 64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to switch it to either int32
or int64
as I needed to do an atomic increment. And since int
will be int64
on most platforms we will be deploying, I thought I would go with int64
.
@@ -139,33 +144,83 @@ func (col *Collection) populateByOptionIdentifier( | |||
return | |||
} | |||
|
|||
limitCh := make(chan struct{}, urlPrefetchChannelBufferSize) | |||
defer close(limitCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be added to the defer on Line 135?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be better to couple it with the make
as the defer above is just for the progressbar.
defer func() { <-limitCh }() | ||
defer wg.Done() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be grouped.
Additionally, a comment would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for grouping them? Let me add comments to it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added comments to the channel creation.
var ( | ||
response absser.Parsable | ||
err error | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several different code declarations. Could it be simplified into the top of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the only declarations in the func called as a goroutine.
5b715e7
to
0b34e2b
Compare
0b34e2b
to
f74663f
Compare
Aviator status
This PR was merged using Aviator. |
Kudos, SonarCloud Quality Gate passed!Β Β 0 Bugs No Coverage information |
Description
From rough numbers we can speedup an account with ~3000 emails, ~1000 contacts and ~1000 events from ~18m to <3m.
Type of change
Issue(s)
Test Plan