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

Implement notifications about idle threads #995

Open
wants to merge 2 commits into
base: onetbb_2021
Choose a base branch
from

Conversation

fwyzard
Copy link

@fwyzard fwyzard commented Dec 20, 2022

Description

Extend the task_scheduler_observer interface with two new methods:

  • on_scheduler_idle(), invoked when a thread does not have any tasks to run and fails to steal any other tasks, before it goes to sleep;
  • on_scheduler_active(), invoked when an idle thread finds a new task to run, after it wakes from sleeping.

Extend the observer_list to notify all observer proxies about the idle and active thread states.

Extend the task_dispatcher to notify about idle and active threads before and after they go to sleep.

Fixes #992

  • - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Does not break API compatibility, may break ABI compatibility for classes that inherit from task_scheduler_observer.

Notify the following users

@pavelkumbrasev

Other information

Extend the task_scheduler_observer interface with two new methods:
  - on_scheduler_idle(), invoked when a worker does not have any tasks
    to run and fails to steal any other tasks, before it goes to sleep;
  - on_scheduler_active(), invoked when an idle worker finds a new task
    to run, after it wakes from sleeping.

Extend the observer_list to notify all observer proxies about the idle
and active thread states.

Extend the task_dispatcher to notify about idle and active threads
before and after they go to sleep.

Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
Use common implementations for do_notify_entry_observers/do_notify_idle_observers
and for do_notify_exit_observers/do_notify_active_observers.

Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

callback on idle threads
2 participants