Skip to content

Commit

Permalink
feat: make worker job polling interval config
Browse files Browse the repository at this point in the history
- Previously, the value was hardcoded to 5000ms. This could lead to long
  wait between processing jobs and hence a delay in result being
  available in the coprocessor db.

- Now, make this interval configurable via command line argument. Can be
  fine tuned as per needed performance.
  • Loading branch information
manoranjith committed Dec 4, 2024
1 parent efaeafa commit 385e85c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions fhevm-engine/coprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Reload database and apply schemas from scratch
make recreate_db
```
Run the server and background fhe worker

```
cargo run -- --run-server --run-bg-worker --worker-polling-interval-ms 1000
```
cargo run -- --run-server --run-bg-worker
```
4 changes: 4 additions & 0 deletions fhevm-engine/coprocessor/src/daemon_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ pub struct Args {
#[arg(long)]
pub run_bg_worker: bool,

/// Polling interval for the background worker to fetch jobs
#[arg(long, default_value_t = 5000)]
pub worker_polling_interval_ms: u64,

/// Generate fhe keys and exit
#[arg(long)]
pub generate_fhe_keys: bool,
Expand Down
2 changes: 1 addition & 1 deletion fhevm-engine/coprocessor/src/tfhe_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async fn tfhe_worker_cycle(
WORK_ITEMS_NOTIFICATIONS_COUNTER.inc();
info!(target: "tfhe_worker", "Received work_available notification from postgres");
},
_ = tokio::time::sleep(tokio::time::Duration::from_millis(5000)) => {
_ = tokio::time::sleep(tokio::time::Duration::from_millis(args.worker_polling_interval_ms)) => {
WORK_ITEMS_POLL_COUNTER.inc();
info!(target: "tfhe_worker", "Polling the database for more work on timer");
},
Expand Down

0 comments on commit 385e85c

Please sign in to comment.