-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
schedule the cycle detector with higher priority using the inject queue #3507
Merged
Merged
Changes from all commits
Commits
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 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 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 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 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 |
---|---|---|
|
@@ -38,6 +38,7 @@ static uint64_t scheduler_suspend_threshold; | |
static PONY_ATOMIC(uint32_t) active_scheduler_count; | ||
static PONY_ATOMIC(uint32_t) active_scheduler_count_check; | ||
static scheduler_t* scheduler; | ||
static pony_ctx_t* inject_context; | ||
static PONY_ATOMIC(bool) detect_quiescence; | ||
static bool use_yield; | ||
static mpmcq_t inject; | ||
|
@@ -847,7 +848,7 @@ static pony_actor_t* steal(scheduler_t* sched) | |
{ | ||
// trigger cycle detector by sending it a message if it is time | ||
uint64_t current_tsc = ponyint_cpu_tick(); | ||
if(ponyint_cycle_check_blocked(&sched->ctx, last_cd_tsc, current_tsc)) | ||
if(ponyint_cycle_check_blocked(last_cd_tsc, current_tsc)) | ||
{ | ||
last_cd_tsc = current_tsc; | ||
|
||
|
@@ -880,6 +881,7 @@ static void run(scheduler_t* sched) | |
last_cd_tsc = 0; | ||
|
||
pony_actor_t* actor = pop_global(sched); | ||
|
||
if (DTRACE_ENABLED(ACTOR_SCHEDULED) && actor != NULL) { | ||
DTRACE2(ACTOR_SCHEDULED, (uintptr_t)sched, (uintptr_t)actor); | ||
} | ||
|
@@ -894,7 +896,7 @@ static void run(scheduler_t* sched) | |
{ | ||
// trigger cycle detector by sending it a message if it is time | ||
uint64_t current_tsc = ponyint_cpu_tick(); | ||
if(ponyint_cycle_check_blocked(&sched->ctx, last_cd_tsc, current_tsc)) | ||
if(ponyint_cycle_check_blocked(last_cd_tsc, current_tsc)) | ||
{ | ||
last_cd_tsc = current_tsc; | ||
|
||
|
@@ -1018,7 +1020,7 @@ static void ponyint_sched_shutdown() | |
ponyint_thread_join(scheduler[i].tid); | ||
|
||
DTRACE0(RT_END); | ||
ponyint_cycle_terminate(&scheduler[0].ctx); | ||
ponyint_cycle_terminate(); | ||
|
||
for(uint32_t i = 0; i < scheduler_count; i++) | ||
{ | ||
|
@@ -1053,6 +1055,7 @@ static void ponyint_sched_shutdown() | |
* sizeof(scheduler_t))); | ||
#endif | ||
scheduler = NULL; | ||
inject_context = NULL; | ||
scheduler_count = 0; | ||
atomic_store_explicit(&active_scheduler_count, 0, memory_order_relaxed); | ||
|
||
|
@@ -1143,7 +1146,9 @@ pony_ctx_t* ponyint_sched_init(uint32_t threads, bool noyield, bool pin, | |
ponyint_mpmcq_init(&inject); | ||
ponyint_asio_init(asio_cpu); | ||
|
||
return pony_ctx(); | ||
inject_context = pony_ctx(); | ||
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. please add code to |
||
|
||
return inject_context; | ||
} | ||
|
||
bool ponyint_sched_start(bool library) | ||
|
@@ -1279,6 +1284,10 @@ void ponyint_sched_maybe_wakeup_if_all_asleep(int32_t current_scheduler_id) | |
} | ||
} | ||
|
||
pony_ctx_t* ponyint_sched_get_inject_context() { | ||
return inject_context; | ||
} | ||
|
||
// Maybe wake up a scheduler thread if possible | ||
void ponyint_sched_maybe_wakeup(int32_t current_scheduler_id) | ||
{ | ||
|
This file contains 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
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.
@ponylang/core how do you folks feel about changing the signature of
ponyint_destroy
to remove thectx
argument? (asking because it's marked asPONY_API
meaning it's a breaking change)