Skip to content

Conversation

@giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Oct 10, 2025

What do these changes do?

This PR updates the Celery worker configuration to use the prefork execution pool for CPU-bound tasks instead of the previous threads pool. The changes improve performance for CPU-intensive tasks by leveraging separate processes rather than threads, which is better suited for Python's GIL limitations.

For CPU-bound (preforked workers), all Celery internal heartbeat mechanisms are now executed in the MainProcess while the tasks run in independent ForkPoolWorkers.

Key changes:

  • Restructured worker module organization to support both thread and prefork pools
  • Added configurable CELERY_POOL environment variable with prefork as default
  • Updated worker initialization to handle process-based workers properly

Related issue/s

How to test

cd packages/celery-library
make tests

Dev-ops

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 49.10714% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.53%. Comparing base (1856258) to head (436e6dc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8500      +/-   ##
==========================================
+ Coverage   87.44%   87.53%   +0.09%     
==========================================
  Files        1959     2008      +49     
  Lines       76525    78421    +1896     
  Branches     1343     1344       +1     
==========================================
+ Hits        66916    68645    +1729     
- Misses       9207     9374     +167     
  Partials      402      402              
Flag Coverage Δ
integrationtests 63.98% <100.00%> (-0.04%) ⬇️
unittests 86.24% <49.10%> (+0.12%) ⬆️
Components Coverage Δ
pkg_aws_library 93.61% <ø> (ø)
pkg_celery_library 83.22% <58.69%> (-2.62%) ⬇️
pkg_dask_task_models_library 79.33% <ø> (ø)
pkg_models_library 92.90% <ø> (ø)
pkg_notifications_library 85.20% <ø> (ø)
pkg_postgres_database 87.95% <ø> (ø)
pkg_service_integration 70.17% <ø> (ø)
pkg_service_library 70.94% <0.00%> (-0.02%) ⬇️
pkg_settings_library 90.29% <100.00%> (+0.09%) ⬆️
pkg_simcore_sdk 84.95% <ø> (-0.06%) ⬇️
agent 93.10% <ø> (ø)
api_server 91.62% <45.45%> (-0.14%) ⬇️
autoscaling 95.00% <ø> (ø)
catalog 92.06% <ø> (ø)
clusters_keeper 99.14% <ø> (ø)
dask_sidecar 92.16% <ø> (-0.23%) ⬇️
datcore_adapter 97.95% <ø> (ø)
director 75.72% <ø> (ø)
director_v2 90.93% <ø> (-0.06%) ⬇️
dynamic_scheduler 96.82% <ø> (ø)
dynamic_sidecar 90.44% <ø> (ø)
efs_guardian 89.83% <ø> (ø)
invitations 90.90% <ø> (ø)
payments 92.80% <ø> (ø)
resource_usage_tracker 92.16% <ø> (∅)
storage 86.97% <22.72%> (+0.38%) ⬆️
webclient ∅ <ø> (∅)
webserver 87.10% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1856258...436e6dc. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mergify
Copy link
Contributor

mergify bot commented Oct 13, 2025

🧪 CI Insights

Here's what we observed from your CI run for 436e6dc.

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on master Retries 🔍 CI Insights 📄 Logs
CI integration-tests You had a 24% chance of failing… lucky you! 🎲 Flaky Configure an automatic retry View View
system-tests You had a 38% chance of failing… lucky you! 🎲 Flaky Configure an automatic retry View View

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Celery worker configuration to use the prefork execution pool for CPU-bound tasks instead of the previous threads pool. The changes improve performance for CPU-intensive tasks by leveraging separate processes rather than threads, which is better suited for Python's GIL limitations.

Key changes:

  • Restructured worker module organization to support both thread and prefork pools
  • Added configurable CELERY_POOL environment variable with prefork as default
  • Updated worker initialization to handle process-based workers properly

Reviewed Changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
services/storage/src/simcore_service_storage/modules/celery/worker_main.py Removed old worker main file
services/storage/src/simcore_service_storage/modules/celery/worker/main.py New worker main with process-aware initialization
services/storage/docker/boot.sh Updated to use new worker module and configurable pool
services/docker-compose.yml Added CELERY_POOL environment variables for different services
services/api-server/ Multiple files updated for module reorganization and import path fixes
packages/settings-library/src/settings_library/celery.py Added CELERY_POOL setting with validation
packages/celery-library/src/celery_library/signals.py Simplified signal handlers for process-based workers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@giancarloromeo
Copy link
Contributor Author

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Oct 17, 2025

queue

🟠 Waiting for conditions to match

  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
      • #approved-reviews-by>=2
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
      • #review-threads-unresolved=0
      • -conflict
      • -draft
      • base=master
      • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
      • label!=🤖-do-not-merge
      • label=🤖-automerge
      • any of: [🛡 GitHub branch protection]
        • check-skipped = deploy to dockerhub
        • check-neutral = deploy to dockerhub
        • check-success = deploy to dockerhub
      • any of: [🛡 GitHub branch protection]
        • check-success = system-tests
        • check-neutral = system-tests
        • check-skipped = system-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = unit-tests
        • check-neutral = unit-tests
        • check-skipped = unit-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = check OAS' are up to date
        • check-neutral = check OAS' are up to date
        • check-skipped = check OAS' are up to date
      • any of: [🛡 GitHub branch protection]
        • check-success = integration-tests
        • check-neutral = integration-tests
        • check-skipped = integration-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = build-test-images (frontend) / build-test-images
        • check-neutral = build-test-images (frontend) / build-test-images
        • check-skipped = build-test-images (frontend) / build-test-images
      • any of: [🛡 GitHub branch protection]
        • check-success = SonarCloud Code Analysis
        • check-neutral = SonarCloud Code Analysis
        • check-skipped = SonarCloud Code Analysis

@sonarqubecloud
Copy link

@giancarloromeo giancarloromeo merged commit 0c9e189 into ITISFoundation:master Oct 17, 2025
243 of 254 checks passed
@giancarloromeo giancarloromeo deleted the is8496/use-prefork-pool-for-cpu-bound-celery-tasks branch October 17, 2025 12:21
giancarloromeo added a commit to giancarloromeo/osparc-simcore that referenced this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:celery-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File export tasks sometimes get stuck

7 participants