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

Use generics in jitter #3717

Merged
merged 9 commits into from
Jan 18, 2023
Merged

Use generics in jitter #3717

merged 9 commits into from
Jan 18, 2023

Conversation

yux0
Copy link
Contributor

@yux0 yux0 commented Dec 16, 2022

What changed?
Use generics in jitter

Why?
Use generics in jitter

How did you test it?

Potential risks

Is hotfix candidate?

@yux0 yux0 marked this pull request as ready for review December 16, 2022 18:25
@yux0 yux0 requested a review from a team as a code owner December 16, 2022 18:25
return base + addon
var base float64
var addon float64
switch i := any(input).(type) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if the compiler is smart enough to compile this into separate functions that don't require a runtime type switch?

Ok, I tried it on compiler explorer and it looks like the answer is no: it makes two separate versions and still has a lot of logic around the type switch

common/backoff/jitter.go Outdated Show resolved Hide resolved
common/backoff/jitter.go Outdated Show resolved Hide resolved
yux0 and others added 4 commits December 21, 2022 10:04
Co-authored-by: David Reiss <dnr@dnr.im>
Co-authored-by: David Reiss <dnr@dnr.im>
@@ -198,7 +198,7 @@ func (r *TaskGeneratorImpl) GenerateWorkflowCloseTasks(
}
// We schedule the archival task for a random time in the near future to avoid sending a surge of tasks
// to the archival system at the same time
delay := backoff.JitDuration(r.config.ArchivalProcessorArchiveDelay(), archivalDelayJitterCoefficient) / 2
delay := backoff.Jitter(r.config.ArchivalProcessorArchiveDelay(), archivalDelayJitterCoefficient) / 2
Copy link
Member

Choose a reason for hiding this comment

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

FullJitter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intentionally skip this because of test verify the jitter. I will see if I can use the full jitter and have the test pass.

@yux0 yux0 merged commit c24c83f into temporalio:master Jan 18, 2023
@yux0 yux0 deleted the jitter branch January 18, 2023 05:08
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