Skip to content

feat: introduce WORKERS_POOL_ENABLED config to optionally disable worker thread pool#5070

Open
quiet-node wants to merge 1 commit intomainfrom
4987-enhance-resource-efficiency-optionally-disable-worker-thread-pool-for-low-memory-profiles
Open

feat: introduce WORKERS_POOL_ENABLED config to optionally disable worker thread pool#5070
quiet-node wants to merge 1 commit intomainfrom
4987-enhance-resource-efficiency-optionally-disable-worker-thread-pool-for-low-memory-profiles

Conversation

@quiet-node
Copy link
Contributor

@quiet-node quiet-node commented Mar 12, 2026

Description

This PR introduces the WORKERS_POOL_ENABLED configuration flag, allowing operators to optionally disable the worker thread pool (piscina). Key changes:

  • Added WORKERS_POOL_ENABLED configuration variable in globalConfig.ts (defaults to true).
  • Refactored WorkersPool.ts to support a "Local Bypass" mode using dynamic imports to load worker logic only when needed.
  • Extracted WorkersErrorUtils.ts to provide standardized error serialization and reconstruction across thread boundaries, preventing circular dependencies.
  • Updated blockWorker.ts and commonWorker.ts to leverage the new error utilities.
  • Added tests

Related issue(s)

Fixes #4987

Testing Guide

  1. Start up the Relay with WORKERS_POOL_ENABLED=false.
  2. Verify that the Relay runs with a lower RSS baseline compared to when workers are enabled.
  3. Run tests (e.g., eth_getLogs, eth_getBlockByNumber) and ensure they complete successfully on the main thread.
  4. Verify that errors (e.g., MirrorNode errors) are still correctly propagated and mapped to JSON-RPC errors.

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

@quiet-node quiet-node added this to the 0.76.0 milestone Mar 12, 2026
@quiet-node quiet-node self-assigned this Mar 12, 2026
@quiet-node quiet-node requested review from a team as code owners March 12, 2026 00:14
@quiet-node quiet-node added the enhancement New feature or request label Mar 12, 2026
@quiet-node quiet-node requested a review from natanasow March 12, 2026 00:14
@quiet-node quiet-node marked this pull request as draft March 12, 2026 00:14
@github-actions
Copy link

github-actions bot commented Mar 12, 2026

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit d8931d9. ± Comparison against base commit 1cfee96.

♻️ This comment has been updated with latest results.

…ker thread pool

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
@quiet-node quiet-node force-pushed the 4987-enhance-resource-efficiency-optionally-disable-worker-thread-pool-for-low-memory-profiles branch from 62801a5 to d8931d9 Compare March 12, 2026 01:45
@quiet-node quiet-node marked this pull request as ready for review March 12, 2026 02:44
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 95.09202% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lay/src/lib/services/workersService/WorkersPool.ts 84.21% 6 Missing ⚠️
...ib/services/ethService/blockService/blockWorker.ts 66.66% 2 Missing ⚠️
@@            Coverage Diff             @@
##             main    #5070      +/-   ##
==========================================
- Coverage   95.90%   95.89%   -0.01%     
==========================================
  Files         144      145       +1     
  Lines       24740    24813      +73     
  Branches     1984     1993       +9     
==========================================
+ Hits        23727    23795      +68     
- Misses        985      990       +5     
  Partials       28       28              
Flag Coverage Δ
config-service 98.49% <100.00%> (+<0.01%) ⬆️
relay 92.25% <88.60%> (-0.03%) ⬇️
server 88.39% <ø> (ø)
ws-server 97.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ckages/config-service/src/services/globalConfig.ts 100.00% <100.00%> (ø)
...rvices/ethService/ethCommonService/commonWorker.ts 98.38% <100.00%> (ø)
...c/lib/services/workersService/WorkersErrorUtils.ts 100.00% <100.00%> (ø)
...s/relay/src/lib/services/workersService/workers.ts 98.57% <100.00%> (+0.13%) ⬆️
...ib/services/ethService/blockService/blockWorker.ts 95.10% <66.66%> (ø)
...lay/src/lib/services/workersService/WorkersPool.ts 97.84% <84.21%> (-2.16%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ferparishuertas Ferparishuertas self-requested a review March 12, 2026 08:27
Copy link
Contributor

@Ferparishuertas Ferparishuertas left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance Resource Efficiency: Optionally Disable Worker Thread Pool for Low-Memory Profiles

3 participants