Skip to content

Commit e7ad9b8

Browse files
authored
fix: Revert queue buffer changes (#648)
1 parent fc97ddc commit e7ad9b8

1 file changed

Lines changed: 17 additions & 39 deletions

File tree

src/jobs/queue.rs

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,22 @@ impl std::fmt::Debug for Queue {
6363
/// Configuration for queue storage tuning.
6464
#[derive(Clone, Debug)]
6565
struct QueueConfig {
66-
/// How often to poll Redis for new jobs (default: 100ms)
67-
poll_interval: Duration,
68-
/// How many jobs to fetch per poll cycle (default: 10)
69-
buffer_size: usize,
7066
/// How often to move scheduled jobs to active queue (default: 30s)
7167
enqueue_scheduled: Duration,
7268
}
7369

7470
impl Default for QueueConfig {
7571
fn default() -> Self {
7672
Self {
77-
poll_interval: Duration::from_millis(100),
78-
buffer_size: 10,
7973
enqueue_scheduled: Duration::from_secs(30),
8074
}
8175
}
8276
}
8377

8478
impl QueueConfig {
85-
/// Configuration for high-throughput queues (transaction_request, transaction_status).
86-
/// - Larger buffer to fetch more jobs per poll
8779
/// - Faster poll interval for lower latency
88-
fn high_throughput() -> Self {
80+
fn high_frequency() -> Self {
8981
Self {
90-
poll_interval: Duration::from_millis(50),
91-
buffer_size: 100,
9282
enqueue_scheduled: Duration::from_secs(2),
9383
}
9484
}
@@ -98,8 +88,6 @@ impl QueueConfig {
9888
/// - Slower scheduled job polling (reduces Redis load)
9989
fn low_frequency() -> Self {
10090
Self {
101-
poll_interval: Duration::from_millis(100),
102-
buffer_size: 10,
10391
enqueue_scheduled: Duration::from_secs(20),
10492
}
10593
}
@@ -122,8 +110,6 @@ impl Queue {
122110
) -> RedisStorage<T> {
123111
let config = Config::default()
124112
.set_namespace(namespace)
125-
.set_poll_interval(queue_config.poll_interval)
126-
.set_buffer_size(queue_config.buffer_size)
127113
.set_enqueue_scheduled(queue_config.enqueue_scheduled);
128114

129115
RedisStorage::new_with_config(conn, config)
@@ -206,53 +192,52 @@ impl Queue {
206192
.unwrap_or_default();
207193

208194
// Queue configurations:
209-
// - High-throughput: transaction_request, transaction_status (critical path)
210-
// - Low-frequency: notifications, health checks, swaps
211-
let high_throughput = QueueConfig::high_throughput();
195+
// - High-frequency: transaction_status (critical path)
196+
// - Low-frequency: request, submission, notifications, health checks, swaps
197+
let high_frequency = QueueConfig::high_frequency();
212198
let low_frequency = QueueConfig::low_frequency();
213199

214200
Ok(Self {
215-
// Critical high-throughput queues
216201
transaction_request_queue: Self::storage(
217202
&format!("{redis_key_prefix}transaction_request_queue"),
218203
conn_tx_request,
219-
high_throughput.clone(),
204+
low_frequency.clone(), // scheduling not used
220205
),
221206
transaction_submission_queue: Self::storage(
222207
&format!("{redis_key_prefix}transaction_submission_queue"),
223208
conn_tx_submit,
224-
high_throughput.clone(),
209+
low_frequency.clone(), // scheduling not used
225210
),
226211
transaction_status_queue: Self::storage(
227212
&format!("{redis_key_prefix}transaction_status_queue"),
228213
conn_status,
229-
high_throughput.clone(),
214+
high_frequency.clone(),
230215
),
231216
transaction_status_queue_evm: Self::storage(
232217
&format!("{redis_key_prefix}transaction_status_queue_evm"),
233218
conn_status_evm,
234-
high_throughput.clone(),
219+
high_frequency.clone(),
235220
),
236221
transaction_status_queue_stellar: Self::storage(
237222
&format!("{redis_key_prefix}transaction_status_queue_stellar"),
238223
conn_status_stellar,
239-
high_throughput,
224+
high_frequency.clone(),
240225
),
241226
// Lower-frequency queues
242227
notification_queue: Self::storage(
243228
&format!("{redis_key_prefix}notification_queue"),
244229
conn_notification,
245-
low_frequency.clone(),
230+
low_frequency.clone(), // scheduling not used
246231
),
247232
token_swap_request_queue: Self::storage(
248233
&format!("{redis_key_prefix}token_swap_request_queue"),
249234
conn_swap,
250-
low_frequency.clone(),
235+
low_frequency.clone(), // scheduling not used
251236
),
252237
relayer_health_check_queue: Self::storage(
253238
&format!("{redis_key_prefix}relayer_health_check_queue"),
254239
conn_health,
255-
low_frequency,
240+
low_frequency.clone(), // scheduling not used
256241
),
257242
redis_connections,
258243
})
@@ -371,36 +356,29 @@ mod tests {
371356
fn test_queue_config_default() {
372357
let config = QueueConfig::default();
373358

374-
assert_eq!(config.poll_interval, Duration::from_millis(100));
375-
assert_eq!(config.buffer_size, 10);
376359
assert_eq!(config.enqueue_scheduled, Duration::from_secs(30));
377360
}
378361

379362
#[test]
380363
fn test_queue_config_high_throughput() {
381-
let config = QueueConfig::high_throughput();
364+
let config = QueueConfig::high_frequency();
382365

383-
// High throughput should have faster polling and larger buffer
384-
assert_eq!(config.poll_interval, Duration::from_millis(50));
385-
assert_eq!(config.buffer_size, 100);
366+
// High frequency should have faster enqueue_scheduled
386367
assert_eq!(config.enqueue_scheduled, Duration::from_secs(2));
387368

388369
// Verify it's faster than default
389370
let default = QueueConfig::default();
390-
assert!(config.poll_interval < default.poll_interval);
391-
assert!(config.buffer_size > default.buffer_size);
371+
assert!(config.enqueue_scheduled < default.enqueue_scheduled);
392372
}
393373

394374
#[test]
395375
fn test_queue_config_low_frequency() {
396376
let config = QueueConfig::low_frequency();
397377

398-
assert_eq!(config.poll_interval, Duration::from_millis(100));
399-
assert_eq!(config.buffer_size, 10);
400378
assert_eq!(config.enqueue_scheduled, Duration::from_secs(20));
401379

402-
// Low frequency should have longer enqueue_scheduled than high throughput
403-
let high = QueueConfig::high_throughput();
380+
// Low frequency should have longer enqueue_scheduled than high frequency
381+
let high = QueueConfig::high_frequency();
404382
assert!(config.enqueue_scheduled > high.enqueue_scheduled);
405383
}
406384
}

0 commit comments

Comments
 (0)