Skip to content

Commit 96f88c5

Browse files
committed
chore(coprocessor): log the progress of a large object fetching from DB
1 parent 312320d commit 96f88c5

6 files changed

Lines changed: 102 additions & 3 deletions

File tree

coprocessor/fhevm-engine/Cargo.lock

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

coprocessor/fhevm-engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ tonic = { version = "0.12.3", features = ["server"] }
4747
tonic-build = "0.12.3"
4848
tracing = "0.1.41"
4949
tracing-subscriber = { version = "0.3.19", features = ["fmt", "json"] }
50+
bytesize = "2.0.1"
5051

5152
[profile.dev.package.tfhe]
5253
overflow-checks = false

coprocessor/fhevm-engine/fhevm-engine-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tfhe = { workspace = true }
2222
tonic = { workspace = true }
2323
tokio = { workspace = true }
2424
tracing = { workspace = true }
25+
bytesize = { workspace = true}
2526

2627
# crates.io dependencies
2728
paste = "1.0.15"

coprocessor/fhevm-engine/fhevm-engine-common/src/tenant_keys.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::utils::safe_deserialize_key;
2+
use bytesize::ByteSize;
23
use sqlx::{
34
postgres::{types::Oid, PgRow},
45
PgPool, Row,
@@ -256,6 +257,9 @@ pub async fn read_large_object_in_chunks(
256257

257258
let mut bytes = Vec::with_capacity(capacity);
258259

260+
let mut timestamp = std::time::Instant::now();
261+
let started_at = std::time::Instant::now();
262+
259263
loop {
260264
let chunk = sqlx::query("SELECT loread($1, $2)")
261265
.bind(fd)
@@ -276,12 +280,33 @@ pub async fn read_large_object_in_chunks(
276280
break;
277281
}
278282
}
283+
284+
// Log progress every 10 seconds
285+
if timestamp.elapsed().as_secs() > 10 {
286+
// calculate the bandwidth of the read operation
287+
let elapsed = started_at.elapsed().as_secs();
288+
let bandwidth = if elapsed > 0 {
289+
bytes.len() as u64 / elapsed
290+
} else {
291+
bytes.len() as u64
292+
};
293+
294+
info!(
295+
"Read {} bytes so far from large object (Oid: {:?}), bandwidth: {}/s",
296+
ByteSize::b(bytes.len() as u64),
297+
large_object_oid,
298+
ByteSize::b(bandwidth)
299+
);
300+
301+
timestamp = std::time::Instant::now();
302+
}
279303
}
280304

281305
info!(
282-
"End of large object ({:?}) reached, result length: {}",
306+
"End of large object ({:?}) reached, result length: {}, elapsed: {}",
283307
large_object_oid,
284-
bytes.len()
308+
ByteSize::b(bytes.len() as u64),
309+
started_at.elapsed().as_secs()
285310
);
286311

287312
let _ = sqlx::query("SELECT lo_close($1)")

coprocessor/fhevm-engine/sns-executor/.sqlx/query-fd37e7dc679caa21ba22d7724a27409c232cceb719aa41a71e7faf44d2cb8ef9.json

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coprocessor/fhevm-engine/sns-executor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ opentelemetry = { workspace = true }
3232
opentelemetry-otlp = { workspace = true }
3333
opentelemetry_sdk = { workspace = true }
3434
opentelemetry-semantic-conventions = { workspace = true }
35+
bytesize = { workspace = true}
3536

3637
# crates.io dependencies
3738
aligned-vec = "0.6.4"
3839
num-traits = "0.2.19"
3940
aws-sdk-s3 = "1.78.0"
40-
bytesize = "2.0.1"
4141
futures = "0.3.31"
4242
humantime = "2.2.0"
4343

0 commit comments

Comments
 (0)