Skip to content

Commit 156814e

Browse files
authored
faet: replace bincode with rkvy (#2023)
1 parent dd79f1f commit 156814e

File tree

12 files changed

+74
-55
lines changed

12 files changed

+74
-55
lines changed

Cargo.toml

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,62 @@ bellatrix = { path = "orion-server/bellatrix" }
3535

3636
context = { path = "context" }
3737

38-
git-internal = "0.4.1"
38+
git-internal = "0.7.3"
3939
libvault-core = "0.1.0"
4040

4141
#====
42-
anyhow = "1.0.100"
42+
anyhow = "1.0.102"
4343
serde = { version = "1.0.228", features = ["derive"] }
4444
serde_json = "1.0.149"
4545
serde_urlencoded = "0.7"
4646
tracing = "0.1.44"
47-
tracing-subscriber = "0.3.22"
47+
tracing-subscriber = "0.3.23"
4848
tracing-appender = "0.2.4"
4949
thiserror = "2.0.18"
50-
clap = "4.5.57"
50+
clap = "4.6.0"
5151

5252
#====
53-
tokio = "1.49.0"
53+
tokio = "1.50.0"
5454
tokio-stream = "0.1.18"
5555
tokio-util = "0.7.18"
5656
async-trait = "0.1.89"
5757
async-stream = "0.3.6"
5858
async-recursion = "1.1.1"
59-
futures = "0.3.31"
60-
futures-util = "0.3.31"
59+
futures = "0.3.32"
60+
futures-util = "0.3.32"
6161
axum = { version = "0.8.8", features = ["macros", "json"] }
6262
axum-extra = "0.12.5"
6363
russh = "0.55.0"
6464
tower-http = "0.6.8"
6565
tower = "0.5.3"
6666
tower-sessions = { version = "0.15", features = ["memory-store"] }
67-
time = { version = "0.3.46", features = ["serde"] }
67+
time = { version = "0.3.47", features = ["serde"] }
6868

6969
#====
7070
sea-orm = "1.1.19"
7171
sea-orm-migration = "1.1.19"
7272

7373
#====
74-
rand = "0.9.2"
74+
rand = "0.10.0"
7575
flate2 = "1.1.9"
7676
smallvec = "1.15.1"
7777
bytes = "1.11.1"
78-
chrono = { version = "0.4.43", features = ["serde"] }
78+
chrono = { version = "0.4.44", features = ["serde"] }
7979
hex = "0.4.3"
8080
sha1 = "0.10"
8181
sha2 = "0.10.9"
8282
rsa = "0.9.10"
8383
hmac = "0.12"
8484

8585
idgenerator = "2.0.0"
86-
config = "0.15.19"
87-
reqwest = "0.13.1"
86+
config = "0.15.21"
87+
reqwest = "0.13.2"
8888
lazy_static = "1.5.0"
89-
uuid = "1.20.0"
89+
uuid = "1.22.0"
9090
regex = "1.12.3"
9191
ed25519-dalek = "2.2.0"
92-
ctrlc = "3.5.1"
93-
cedar-policy = "4.8.2"
92+
ctrlc = "3.5.2"
93+
cedar-policy = "4.9.1"
9494
secp256k1 = "0.30.0"
9595
pgp = "0.15.0"
9696
oauth2 = "5.0.0"
@@ -99,13 +99,13 @@ base64 = "0.22.1"
9999
utoipa = { version = "5.4.0", features = ["chrono"] }
100100
utoipa-axum = "0.2.0"
101101
utoipa-swagger-ui = "9.0.2"
102-
tempfile = "3.24.0"
102+
tempfile = "3.27.0"
103103
rdkafka = "0.39.0"
104104
dashmap = "6.1.0"
105-
once_cell = "1.21.3"
106-
testcontainers = "0.26.3"
105+
once_cell = "1.21.4"
106+
testcontainers = "0.27.1"
107107
scopeguard = "1.2.0"
108-
serial_test = "3.3.1"
108+
serial_test = "3.4.0"
109109
sysinfo = "0.38"
110110
http = "1.4.0"
111111
http-body = "1.0.1"
@@ -115,34 +115,33 @@ path-absolutize = "3.1.1"
115115
url = "2.5.8"
116116
jemallocator = "0.5.4"
117117
mimalloc = "0.1.48"
118-
assert_cmd = "2.1.2"
118+
assert_cmd = "2.2.0"
119119
dotenvy = "0.15.7"
120120
tokio-tungstenite = "0.28"
121121
tungstenite = "0.28"
122122
itertools = "0.14.0"
123123
bs58 = "0.5.1"
124-
syn = "2.0.114"
125-
quote = "1.0.43"
126-
proc-macro2 = "1.0.105"
124+
syn = "2.0"
125+
quote = "1.0.45"
126+
proc-macro2 = "1.0.106"
127127
log = "0.4.29"
128-
env_logger = "0.11.8"
129-
qdrant-client = "1.16"
128+
env_logger = "0.11.9"
129+
qdrant-client = "1.17"
130130
walkdir = "2.5"
131131
dagrs = "0.6.0"
132132
tar = "0.4"
133133
indexmap = "2.13"
134134
envsubst = "0.2.1"
135135
directories = "6.0.0"
136136
dotenv = "0.15"
137-
redis = "1.0.3"
138-
redis-test = "1.0.1"
139-
bincode = "2.0.1"
140-
rustls = "0.23.36"
137+
redis = "1.0.5"
138+
redis-test = "1.0.2"
139+
rustls = "0.23.37"
141140
object_store = "0.13.1"
142-
parse-display = "0.8.2"
143-
qlean = "0.2.2"
141+
parse-display = "0.10.0"
142+
qlean = "0.2.3"
144143
toml = "0.9.8"
145-
144+
rkyv = "0.8.15"
146145

147146
[profile.release]
148147
debug = true

ceres/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ regex = { workspace = true }
4343
tokio-util = { workspace = true }
4444
uuid = { workspace = true, features = ["v4"] }
4545
redis = { workspace = true }
46-
bincode = { workspace = true }
4746
sha1 = { workspace = true }
4847
hex = { workspace = true }
48+
rkyv = { workspace = true }
4949

5050
[dev-dependencies]
5151
tempfile = { workspace = true }

ceres/src/api_service/cache.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ use std::sync::Arc;
33
use common::errors::MegaError;
44
use git_internal::{
55
hash::ObjectHash,
6-
internal::object::{commit::Commit, tree::Tree},
6+
internal::object::{
7+
commit::{ArchivedCommit, Commit},
8+
tree::{ArchivedTree, Tree},
9+
},
710
};
811
use redis::{AsyncCommands, aio::ConnectionManager};
12+
use rkyv::rancor::Error;
913

1014
#[derive(Clone)]
1115
pub struct GitObjectCache {
1216
pub connection: ConnectionManager,
1317
pub prefix: String,
1418
}
1519

16-
const DEFAULT_EXPIRY_SECONDS: u64 = 60 * 60 * 24 * 7; // 7 days
20+
const DEFAULT_EXPIRY_SECONDS: u64 = 60 * 60 * 24; // 1 days
1721

1822
impl GitObjectCache {
1923
pub async fn get_tree<F, Fut>(
@@ -30,16 +34,24 @@ impl GitObjectCache {
3034

3135
if let Ok(data) = conn.get::<_, Vec<u8>>(&key).await
3236
&& !data.is_empty()
33-
&& let Ok((tree, _)) = bincode::decode_from_slice(&data, bincode::config::standard())
3437
{
35-
return Ok(Arc::new(tree));
38+
match rkyv::access::<ArchivedTree, Error>(&data) {
39+
Ok(archived) => {
40+
let tree = rkyv::deserialize::<Tree, Error>(archived)?;
41+
return Ok(Arc::new(tree));
42+
}
43+
Err(err) => {
44+
tracing::error!("deserialize failed with fetch key: {:?}, err{:?}", key, err);
45+
}
46+
}
3647
}
3748

3849
let tree_raw = fetch_tree(oid).await?;
50+
let serialized = rkyv::to_bytes::<Error>(&tree_raw)?;
3951
let tree = Arc::new(tree_raw);
40-
41-
let serialized = bincode::encode_to_vec(tree.as_ref(), bincode::config::standard())?;
42-
let _: () = conn.set_ex(key, serialized, DEFAULT_EXPIRY_SECONDS).await?;
52+
let _: () = conn
53+
.set_ex(key, serialized.as_slice(), DEFAULT_EXPIRY_SECONDS)
54+
.await?;
4355

4456
Ok(tree)
4557
}
@@ -58,16 +70,24 @@ impl GitObjectCache {
5870

5971
if let Ok(data) = conn.get::<_, Vec<u8>>(&key).await
6072
&& !data.is_empty()
61-
&& let Ok((commit, _)) = bincode::decode_from_slice(&data, bincode::config::standard())
6273
{
63-
return Ok(Arc::new(commit));
74+
match rkyv::access::<ArchivedCommit, Error>(&data) {
75+
Ok(archived) => {
76+
let commit = rkyv::deserialize::<Commit, Error>(archived)?;
77+
return Ok(Arc::new(commit));
78+
}
79+
Err(err) => {
80+
tracing::error!("deserialize failed with fetch key: {:?} err{:?}", key, err);
81+
}
82+
}
6483
}
6584

6685
let commit_raw = fetch_commit(oid).await?;
86+
let serialized = rkyv::to_bytes::<Error>(&commit_raw)?;
6787
let commit = Arc::new(commit_raw);
68-
69-
let serialized = bincode::encode_to_vec(commit.as_ref(), bincode::config::standard())?;
70-
let _: () = conn.set_ex(key, serialized, DEFAULT_EXPIRY_SECONDS).await?;
88+
let _: () = conn
89+
.set_ex(key, serialized.as_slice(), DEFAULT_EXPIRY_SECONDS)
90+
.await?;
7191

7292
Ok(commit)
7393
}

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ directories = { workspace = true }
2828
pgp = { workspace = true }
2929
cedar-policy = { workspace = true }
3030
redis = { workspace = true }
31-
bincode = { workspace = true }
31+
rkyv = { workspace = true}
3232
toml = { workspace = true }

common/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub enum MegaError {
2323
#[error("Redis error: {0}")]
2424
Redis(#[from] redis::RedisError),
2525

26-
#[error("Bincode encode error: {0}")]
27-
EncodeError(#[from] bincode::error::EncodeError),
26+
#[error("serialization error: {0}")]
27+
EncodeError(#[from] rkyv::rancor::Error),
2828

2929
// --- Serialization / parsing ---
3030
#[error("JSON serialization error: {0}")]

jupiter/callisto/src/entity_ext/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub mod mega_refs;
1818
pub mod reactions;
1919

2020
use idgenerator::IdInstance;
21-
use rand::Rng;
21+
use rand::RngExt;
2222
use sha2::{Digest, Sha256};
2323

2424
pub fn generate_id() -> i64 {

mono/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ---------- planner stage ----------
22
# This stage analyzes the Cargo workspace and produces a dependency recipe.
33
# The recipe will change ONLY when Cargo.toml changes.
4-
FROM rust:1.93.0-bookworm AS chef
4+
FROM rust:1.94.0-bookworm AS chef
55

66
WORKDIR /opt/mega
77

mono/src/server/http_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub async fn app(ctx: AppContext, host: String, port: u16) -> Router {
249249
let oauth_config = config.oauth.clone();
250250
let git_object_cache = Arc::new(GitObjectCache {
251251
connection: ctx.connection.clone(),
252-
prefix: "git-object-bincode".to_string(),
252+
prefix: "git-object-rkyv:v1".to_string(),
253253
});
254254

255255
let api_state = MonoApiServiceState {

mono/src/server/ssh_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub async fn start_server(ctx: AppContext, command: &SshOptions) {
5656
storage: ctx.storage.clone(),
5757
git_object_cache: Arc::new(GitObjectCache {
5858
connection: ctx.connection.clone(),
59-
prefix: "git-object-bincode".to_string(),
59+
prefix: "git-object-rkyv:v1".to_string(),
6060
}),
6161
};
6262
let mut ssh_server = SshServer {

orion-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ────── Stage 0: Chef ──────
2-
FROM rust:1.93.0-bookworm AS chef
2+
FROM rust:1.94.0-bookworm AS chef
33
RUN cargo install cargo-chef --version 0.1.73
44
WORKDIR /app
55

0 commit comments

Comments
 (0)