-
Notifications
You must be signed in to change notification settings - Fork 92
[DRAFT] Process wide worker heartbeat #962
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
Closed
yuandrew
wants to merge
13
commits into
temporalio:master
from
yuandrew:process-wide-worker-heartbeat
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e5df62f
Heartbeat moved to process level, need to create and async poll pollers
yuandrew 42c050d
before moving heartbeat to a per-namespace level
yuandrew a062614
moved heartbeat to per-namespace level
yuandrew 0c549cd
Clean up
yuandrew 9e5ac93
worker heartbeat refactored, need to do nexus now
yuandrew fdd6f29
Update API to Yuri's branch, ee2bd590b4ad3d0b6df8d6ea948dd3cf8f518129
yuandrew 0b040fa
Core logic implemented, need to clean up and finish implementing TODO…
yuandrew f1099f6
need to get rid of Arc<Mutex<>> of worker_data_map
yuandrew d49b19c
Add in shutdown flow
yuandrew 9ee8ee6
WIP, fixing test
yuandrew 3c3af9c
Made WorkerConfigInner, code compiles, need to fix test
yuandrew e93b015
git merge main
yuandrew 6d2dc1a
Merge branch 'master' into process-wide-worker-heartbeat
yuandrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,8 @@ pub(crate) struct MeteredPermitDealer<SK: SlotKind> { | |
/// is at this number, no more permits will be requested from the supplier until one is freed. | ||
/// This avoids requesting slots when we are at the workflow cache size limit. If and when | ||
/// we add user-defined cache sizing, that logic will need to live with the supplier and | ||
/// there will need to be some associated refactoring. | ||
max_permits: Option<usize>, | ||
/// there will need to be some associated refactoring. // TODO: sounds like we'll need to do this | ||
max_permits: Option<Arc<AtomicUsize>>, | ||
Comment on lines
+39
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potentially, yes. Let's leave proper implementations of the commands for later though, since this PR is already quite large, and they won't be working server side for a while anyway. |
||
metrics_ctx: MetricsContext, | ||
meter: Option<TemporalMeter>, | ||
/// Only applies to permit dealers for workflow tasks. True if this permit dealer is associated | ||
|
@@ -61,7 +61,7 @@ where | |
pub(crate) fn new( | ||
supplier: Arc<dyn SlotSupplier<SlotKind = SK> + Send + Sync>, | ||
metrics_ctx: MetricsContext, | ||
max_permits: Option<usize>, | ||
max_permits: Option<Arc<AtomicUsize>>, | ||
context_data: Arc<PermitDealerContextData>, | ||
meter: Option<TemporalMeter>, | ||
) -> Self { | ||
|
@@ -88,11 +88,11 @@ where | |
} | ||
|
||
pub(crate) async fn acquire_owned(&self) -> OwnedMeteredSemPermit<SK> { | ||
if let Some(max) = self.max_permits { | ||
if let Some(ref max) = self.max_permits { | ||
self.extant_permits | ||
.1 | ||
.clone() | ||
.wait_for(|&ep| ep < max) | ||
.wait_for(|&ep| ep < max.load(Ordering::Relaxed)) | ||
.await | ||
.expect("Extant permit channel is never closed"); | ||
} | ||
|
@@ -101,8 +101,8 @@ where | |
} | ||
|
||
pub(crate) fn try_acquire_owned(&self) -> Result<OwnedMeteredSemPermit<SK>, ()> { | ||
if let Some(max) = self.max_permits | ||
&& *self.extant_permits.1.borrow() >= max | ||
if let Some(ref max) = self.max_permits | ||
&& *self.extant_permits.1.borrow() >= max.load(Ordering::Relaxed) | ||
{ | ||
return Err(()); | ||
} | ||
|
@@ -482,7 +482,7 @@ pub(crate) mod tests { | |
#[tokio::test] | ||
async fn respects_max_extant_permits() { | ||
let mut sem = fixed_size_permit_dealer::<WorkflowSlotKind>(2); | ||
sem.max_permits = Some(1); | ||
sem.max_permits = Some(Arc::new(AtomicUsize::new(1))); | ||
let perm = sem.try_acquire_owned().unwrap(); | ||
sem.try_acquire_owned().unwrap_err(); | ||
let acquire_fut = sem.acquire_owned(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This shouldn't need to have changed I think