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

limit offchain threads #1630

Merged
merged 4 commits into from
May 29, 2023
Merged

limit offchain threads #1630

merged 4 commits into from
May 29, 2023

Conversation

turuslan
Copy link
Contributor

Referenced issues

Description of the Change

  • Limit max offchain threads.
  • Limit offchain tasks queue.
  • Drop old offchain tasks when queue if full.

Benefits

  • Limit offchain threads

Possible Drawbacks

Signed-off-by: turuslan <turuslan.devbox@gmail.com>
@iceseer iceseer self-requested a review May 24, 2023 12:15
@turuslan turuslan requested a review from xDimon May 24, 2023 12:15
core/utils/thread_pool.hpp Show resolved Hide resolved
core/offchain/impl/runner.hpp Outdated Show resolved Hide resolved
turuslan added 3 commits May 24, 2023 21:08
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
using Task = std::function<void()>;

Runner(size_t threads, size_t max_tasks)
: threads_{threads},
Copy link
Contributor

Choose a reason for hiding this comment

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

мне кажется не стоит тут порождать потоки, у нас уже создается пулл для фоновых задач и можно выполнять в нем https://imgur.com/7zEUjSI.png
А в пулле нам по сути без разницы на какую работу тратится время пулла, от этого ресурсов больше не станет, так что счетчик max_tasks будет нормально работать.
Зато в дальнейшем это даст например возможность ограничить этим же кодом некоторые задачи в парачейнах.

@iceseer iceseer self-requested a review May 29, 2023 07:04
@turuslan turuslan merged commit e7bdb9e into master May 29, 2023
@turuslan turuslan deleted the offchain/threads branch May 29, 2023 07:06
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