Skip to content

Implement internal API for running current event loop #3641

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

Merged
merged 9 commits into from
Mar 3, 2023

Conversation

qwwdfsad
Copy link
Collaborator

Fixes #3439

while (start != end && blockingTasksInBuffer.value > 0) {
val task = tryExtractBlockingTask(--end)
// CPU or (BLOCKING & hasBlocking)
val shouldProceed = !onlyBlocking || blockingTasksInBuffer.value > 0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shouldProceed isn't updated deliberately, I find making it as part of while a bit more compact

@qwwdfsad qwwdfsad requested a review from dkhalanskyjb March 3, 2023 15:20
while (start != end && blockingTasksInBuffer.value > 0) {
val task = tryExtractBlockingTask(--end)
// Bail out if there is no blocking work for us
if (onlyBlocking && blockingTasksInBuffer.value == 0) return null
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is still a mystery to me why we don't do it on every iteration any longer. Could you drop a comment in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My idea was to check it once and then look for the task. The only scenario where the task is not found is when another thread decides to steal a blocking task from the very same queue, which is not very likely. Effectively, I traded a negligible part of "slow path" ("unlikely event happened") performance for the same negligible benefit on "fast path".

It's unlikely to matter in reality, so readability/maintainability must be preferred; I'll rollback the change

Copy link
Collaborator

Choose a reason for hiding this comment

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

This particular place still has the change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I would be okay with it if it had a corresponding comment and, preferably, was in a separate commit (this one is a bit loaded with changes already).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I probably have to stop pushing any changes around Friday's evenings 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively, you could embrace the flow, go for it, and publish a release today.

@qwwdfsad qwwdfsad requested a review from dkhalanskyjb March 3, 2023 15:31
while (start != end && blockingTasksInBuffer.value > 0) {
val task = tryExtractBlockingTask(--end)
// Bail out if there is no blocking work for us
if (onlyBlocking && blockingTasksInBuffer.value == 0) return null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I would be okay with it if it had a corresponding comment and, preferably, was in a separate commit (this one is a bit loaded with changes already).

@qwwdfsad qwwdfsad merged commit bddfb89 into develop Mar 3, 2023
@qwwdfsad qwwdfsad deleted the scheduler-idea-api branch March 3, 2023 15:45
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.

2 participants