tracks lexicons and how many times they appeared on the jetstream

refactor(server): use mimalloc

ptr.pet 9581c553 c2522740

verified
Changed files
+29 -39
.tangled
workflows
server
-2
.tangled/workflows/build.yml
···
- bun
- curl
- gcc
-
- cmake
-
- gnumake
steps:
- name: test server
+20 -28
server/Cargo.lock
···
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
-
name = "cmake"
-
version = "0.1.54"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
-
dependencies = [
-
"cc",
-
]
-
-
[[package]]
name = "combine"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
[[package]]
+
name = "libmimalloc-sys"
+
version = "0.1.43"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bf88cd67e9de251c1781dbe2f641a1a3ad66eaae831b8a2c38fbdc5ddae16d4d"
+
dependencies = [
+
"cc",
+
"libc",
+
]
+
+
[[package]]
name = "linux-raw-sys"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
[[package]]
+
name = "mimalloc"
+
version = "0.1.47"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b1791cbe101e95af5764f06f20f6760521f7158f69dbf9d6baf941ee1bf6bc40"
+
dependencies = [
+
"libmimalloc-sys",
+
]
+
+
[[package]]
name = "mime"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"fjall",
"futures-util",
"itertools",
+
"mimalloc",
"ordered-varint",
"parking_lot",
"quanta",
···
"serde",
"serde_json",
"smol_str",
-
"snmalloc-rs",
"threadpool",
"tokio",
"tokio-util",
···
dependencies = [
"borsh",
"serde",
-
]
-
-
[[package]]
-
name = "snmalloc-rs"
-
version = "0.3.8"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "eb317153089fdfa4d8a2eec059d40a5a23c3bde43995ea23b19121c3f621e74a"
-
dependencies = [
-
"snmalloc-sys",
-
]
-
-
[[package]]
-
name = "snmalloc-sys"
-
version = "0.3.8"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "065fea53d32bb77bc36cca466cb191f2e5216ebfd0ed360b1d64889ee6e559ea"
-
dependencies = [
-
"cmake",
[[package]]
+1 -1
server/Cargo.toml
···
rayon = "1.10.0"
parking_lot = { version = "0.12", features = ["send_guard", "hardware-lock-elision"] }
rclite = "0.2.7"
-
snmalloc-rs = "0.3.8"
arc-swap = "1.7.1"
ahash = { version = "0.8.12", features = ["serde"] }
+
mimalloc = "*"
+7 -7
server/src/db/mod.rs
···
let _guard = scc::ebr::Guard::new();
for (nsid, handle) in self.hits.iter(&_guard) {
let mut nsid_data = Vec::with_capacity(2);
-
let mut total_count = 0;
+
// let mut total_count = 0;
let is_too_old = handle.since_last_activity() > self.cfg.max_last_activity;
// if we disconnect for a long time, we want to sync all of what we
// have to avoid having many small blocks (even if we run compaction
···
if count > 0 && (all || data_count > 0 || is_too_old) {
for _ in 0..data_count {
nsid_data.push((handle.clone(), block_size));
-
total_count += block_size;
+
// total_count += block_size;
}
// only sync remainder if we haven't met block size
let remainder = count % block_size;
if (all || data_count == 0) && remainder > 0 {
nsid_data.push((handle.clone(), remainder));
-
total_count += remainder;
+
// total_count += remainder;
}
}
let _span = handle.span().entered();
if nsid_data.len() > 0 {
-
tracing::info!(
-
{blocks = %nsid_data.len(), count = %total_count},
-
"will encode & sync",
-
);
+
// tracing::info!(
+
// {blocks = %nsid_data.len(), count = %total_count},
+
// "will encode & sync",
+
// );
nsids.insert(nsid.clone());
data.push(nsid_data);
}
+1 -1
server/src/main.rs
···
mod utils;
#[global_allocator]
-
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[tokio::main]
async fn main() {