Skip to content

Commit f839f01

Browse files
authored
fix: remove delay in publish_batch execution (#109)
The existing code creates futures for publish_batch with delays to spread the rpc load evenly in the publish interval however due to the Rust async design those futures do not get started unless they are awaited. This results in additional deterministic latency of almost the publish_interval especially for the publishers who publish many prices. This change removes the code as even the intended behaviour adds latency and disrupts the publish interval (the last publish_batch can block the actor loop).
1 parent 670c080 commit f839f01

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-agent"
3-
version = "2.5.0"
3+
version = "2.5.1"
44
edition = "2021"
55

66
[[bin]]

src/agent/solana/exporter.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,23 +527,15 @@ impl Exporter {
527527
// Split the updates up into batches
528528
let batches = permissioned_updates.chunks(self.config.max_batch_size);
529529

530-
// Publish all the batches, staggering the requests over the publish interval
531-
let num_batches = batches.len();
532-
let mut batch_send_interval = time::interval(
533-
self.config
534-
.publish_interval_duration
535-
.div_f64((num_batches + 1) as f64), // +1 to give enough time for the last batch
536-
);
537530
let mut batch_state = HashMap::new();
538531
let mut batch_futures = vec![];
532+
539533
for batch in batches {
540534
batch_futures.push(self.publish_batch(batch));
541535

542536
for (identifier, info) in batch {
543537
batch_state.insert(*identifier, (*info).clone());
544538
}
545-
546-
batch_send_interval.tick().await;
547539
}
548540

549541
// Wait for all the update requests to complete. Note that this doesn't wait for the

0 commit comments

Comments
 (0)