django-vcache 2.3.0__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_vcache-2.3.0 → django_vcache-3.1.0}/Cargo.lock +3 -3
- {django_vcache-2.3.0 → django_vcache-3.1.0}/Cargo.toml +1 -1
- {django_vcache-2.3.0 → django_vcache-3.1.0}/PKG-INFO +1 -1
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/Cargo.toml +3 -1
- django_vcache-3.1.0/crates/vcache-core/examples/bench.rs +152 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/src/connection.rs +367 -132
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/src/lib.rs +2 -1
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/src/runtime.rs +25 -12
- django_vcache-3.1.0/crates/vcache-pyo3/src/async_bridge.rs +706 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-pyo3/src/client.rs +54 -14
- django_vcache-3.1.0/crates/vcache-pyo3/src/completion.rs +262 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-pyo3/src/lib.rs +5 -0
- django_vcache-3.1.0/django_vcache/__init__.py +13 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/django_vcache/backend.py +142 -50
- django_vcache-3.1.0/django_vcache/exceptions.py +8 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/pyproject.toml +1 -1
- django_vcache-2.3.0/crates/vcache-pyo3/src/async_bridge.rs +0 -395
- django_vcache-2.3.0/django_vcache/__init__.py +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/LICENSE +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/README.md +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/examples/standalone.rs +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/src/result.rs +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-core/tests/runtime_provider.rs +0 -0
- {django_vcache-2.3.0 → django_vcache-3.1.0}/crates/vcache-pyo3/Cargo.toml +0 -0
|
@@ -725,7 +725,7 @@ dependencies = [
|
|
|
725
725
|
|
|
726
726
|
[[package]]
|
|
727
727
|
name = "rlib-link-test"
|
|
728
|
-
version = "
|
|
728
|
+
version = "3.1.0"
|
|
729
729
|
dependencies = [
|
|
730
730
|
"pyo3",
|
|
731
731
|
"vcache-pyo3",
|
|
@@ -1005,7 +1005,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
|
|
1005
1005
|
|
|
1006
1006
|
[[package]]
|
|
1007
1007
|
name = "vcache-core"
|
|
1008
|
-
version = "
|
|
1008
|
+
version = "3.1.0"
|
|
1009
1009
|
dependencies = [
|
|
1010
1010
|
"redis",
|
|
1011
1011
|
"rustls",
|
|
@@ -1014,7 +1014,7 @@ dependencies = [
|
|
|
1014
1014
|
|
|
1015
1015
|
[[package]]
|
|
1016
1016
|
name = "vcache-pyo3"
|
|
1017
|
-
version = "
|
|
1017
|
+
version = "3.1.0"
|
|
1018
1018
|
dependencies = [
|
|
1019
1019
|
"pyo3",
|
|
1020
1020
|
"redis",
|
|
@@ -9,7 +9,9 @@ license = "MIT"
|
|
|
9
9
|
name = "vcache_core"
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
12
|
-
|
|
12
|
+
# "sync" is used directly (RwLock, OnceCell, Mutex) — declared explicitly
|
|
13
|
+
# rather than relying on feature unification through redis's tokio dep.
|
|
14
|
+
tokio = { workspace = true, features = ["sync"] }
|
|
13
15
|
redis.workspace = true
|
|
14
16
|
rustls.workspace = true
|
|
15
17
|
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//! Pure-Rust driver benchmark: the ceiling for downstream Rust consumers
|
|
2
|
+
//! that call `ValkeyConn` directly (reusing the shared tokio runtime),
|
|
3
|
+
//! bypassing the Python bridge entirely.
|
|
4
|
+
//!
|
|
5
|
+
//! Mirrors bench_vs.py's raw scenarios (128-byte values, sequential
|
|
6
|
+
//! set/get/incr/lpush/rpop + 200-task concurrent set+get) so the numbers
|
|
7
|
+
//! are directly comparable. Run inside the app container, ideally with the
|
|
8
|
+
//! same tc netem latency as the Python benchmarks:
|
|
9
|
+
//!
|
|
10
|
+
//! tc qdisc add dev eth0 root netem delay 1ms
|
|
11
|
+
//! cargo run --release --example bench
|
|
12
|
+
|
|
13
|
+
use std::time::Instant;
|
|
14
|
+
use vcache_core::{connect_standard, get_runtime};
|
|
15
|
+
|
|
16
|
+
const N_SEQ: usize = 1500;
|
|
17
|
+
const CONC_TASKS: usize = 200;
|
|
18
|
+
const CONC_ITERS: usize = 25;
|
|
19
|
+
|
|
20
|
+
fn cpu_seconds() -> f64 {
|
|
21
|
+
// utime + stime from /proc/self/stat, in clock ticks (100 Hz on Linux).
|
|
22
|
+
// comm can contain spaces/parens; fields start after the last ')'.
|
|
23
|
+
let stat = std::fs::read_to_string("/proc/self/stat").unwrap();
|
|
24
|
+
let fields: Vec<&str> = stat[stat.rfind(')').unwrap() + 2..]
|
|
25
|
+
.split_whitespace()
|
|
26
|
+
.collect();
|
|
27
|
+
let utime: f64 = fields[11].parse().unwrap();
|
|
28
|
+
let stime: f64 = fields[12].parse().unwrap();
|
|
29
|
+
(utime + stime) / 100.0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fn rss_mb() -> f64 {
|
|
33
|
+
let status = std::fs::read_to_string("/proc/self/status").unwrap();
|
|
34
|
+
for line in status.lines() {
|
|
35
|
+
if let Some(rest) = line.strip_prefix("VmRSS:") {
|
|
36
|
+
let kb: f64 = rest.trim().trim_end_matches("kB").trim().parse().unwrap();
|
|
37
|
+
return kb / 1024.0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
0.0
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fn report(name: &str, wall: f64, cpu: f64, ops: usize) {
|
|
44
|
+
println!(
|
|
45
|
+
"{name:>14} wall {:>9.1} us/op cpu {:>7.1} us/op ({ops} ops)",
|
|
46
|
+
wall / ops as f64 * 1e6,
|
|
47
|
+
cpu / ops as f64 * 1e6,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fn main() {
|
|
52
|
+
let url = std::env::var("VALKEY_URL").unwrap_or_else(|_| "redis://valkey:6379/1".into());
|
|
53
|
+
let value = vec![b'x'; 128];
|
|
54
|
+
|
|
55
|
+
get_runtime().block_on(async move {
|
|
56
|
+
let mut conn = connect_standard(&url, None, None)
|
|
57
|
+
.await
|
|
58
|
+
.expect("connect failed");
|
|
59
|
+
|
|
60
|
+
// Warmup
|
|
61
|
+
for i in 0..100 {
|
|
62
|
+
let k = format!("rw{i}");
|
|
63
|
+
conn.set_bytes(&k, value.clone(), Some(300)).await.unwrap();
|
|
64
|
+
conn.get_bytes(&k).await.unwrap();
|
|
65
|
+
}
|
|
66
|
+
println!("baseline RSS: {:.1} MB", rss_mb());
|
|
67
|
+
|
|
68
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
69
|
+
for i in 0..N_SEQ {
|
|
70
|
+
let k = format!("rk{}", i % 100);
|
|
71
|
+
conn.set_bytes(&k, value.clone(), Some(300)).await.unwrap();
|
|
72
|
+
}
|
|
73
|
+
report(
|
|
74
|
+
"seq_set",
|
|
75
|
+
w0.elapsed().as_secs_f64(),
|
|
76
|
+
cpu_seconds() - c0,
|
|
77
|
+
N_SEQ,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
81
|
+
for i in 0..N_SEQ {
|
|
82
|
+
let k = format!("rk{}", i % 100);
|
|
83
|
+
conn.get_bytes(&k).await.unwrap();
|
|
84
|
+
}
|
|
85
|
+
report(
|
|
86
|
+
"seq_get",
|
|
87
|
+
w0.elapsed().as_secs_f64(),
|
|
88
|
+
cpu_seconds() - c0,
|
|
89
|
+
N_SEQ,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
93
|
+
for _ in 0..N_SEQ {
|
|
94
|
+
conn.incr_by("rctr", 1).await.unwrap();
|
|
95
|
+
}
|
|
96
|
+
report(
|
|
97
|
+
"seq_incr",
|
|
98
|
+
w0.elapsed().as_secs_f64(),
|
|
99
|
+
cpu_seconds() - c0,
|
|
100
|
+
N_SEQ,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
104
|
+
for _ in 0..N_SEQ {
|
|
105
|
+
conn.lpush("rq", vec![value.clone()]).await.unwrap();
|
|
106
|
+
}
|
|
107
|
+
report(
|
|
108
|
+
"seq_lpush",
|
|
109
|
+
w0.elapsed().as_secs_f64(),
|
|
110
|
+
cpu_seconds() - c0,
|
|
111
|
+
N_SEQ,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
115
|
+
for _ in 0..N_SEQ {
|
|
116
|
+
conn.rpop("rq").await.unwrap();
|
|
117
|
+
}
|
|
118
|
+
report(
|
|
119
|
+
"seq_rpop",
|
|
120
|
+
w0.elapsed().as_secs_f64(),
|
|
121
|
+
cpu_seconds() - c0,
|
|
122
|
+
N_SEQ,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Concurrent set+get across cloned connections (shared multiplexed TCP)
|
|
126
|
+
let (w0, c0) = (Instant::now(), cpu_seconds());
|
|
127
|
+
let mut handles = Vec::with_capacity(CONC_TASKS);
|
|
128
|
+
for t in 0..CONC_TASKS {
|
|
129
|
+
let mut c = conn.clone();
|
|
130
|
+
let v = value.clone();
|
|
131
|
+
handles.push(tokio::spawn(async move {
|
|
132
|
+
for i in 0..CONC_ITERS {
|
|
133
|
+
let k = format!("rc{t}_{}", i % 10);
|
|
134
|
+
c.set_bytes(&k, v.clone(), Some(300)).await.unwrap();
|
|
135
|
+
c.get_bytes(&k).await.unwrap();
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
for h in handles {
|
|
140
|
+
h.await.unwrap();
|
|
141
|
+
}
|
|
142
|
+
report(
|
|
143
|
+
"conc_setget",
|
|
144
|
+
w0.elapsed().as_secs_f64(),
|
|
145
|
+
cpu_seconds() - c0,
|
|
146
|
+
CONC_TASKS * CONC_ITERS * 2,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
println!("final RSS: {:.1} MB", rss_mb());
|
|
150
|
+
conn.flushdb().await.unwrap();
|
|
151
|
+
});
|
|
152
|
+
}
|