|
|
hai 3 meses | |
|---|---|---|
| .. | ||
| README.md | hai 3 meses | |
| config.json | hai 3 meses | |
| load_test.cpp | hai 3 meses | |
Standalone binary that validates v1.7.0's chunked eviction + admission control + client retry against a real smartbotic-database instance.
Not a unit test — runs a real server on a configurable port, hammers it with concurrent inserts, and reports success/failure counts + a pressure-level timeline.
smartbotic-database package installed (for the server binary)libsmartbotic-db-client-dev installed (for headers + shared lib)cd tests/load_test
g++ -std=c++20 -O2 -I/usr/include load_test.cpp \
-lsmartbotic-db-client \
$(pkg-config --libs grpc++) \
-lspdlog -lfmt -pthread \
-o load_test
Uses port 9005 and data dir /tmp/smartbotic-loadtest/ to avoid conflicting with any existing instance on the default port 9004.
# 1. Start the test server with its own config (memory capped at 32 MB)
mkdir -p /tmp/smartbotic-loadtest/data /tmp/smartbotic-loadtest/files
smartbotic-database --config ./config.json > /tmp/smartbotic-loadtest/server.log 2>&1 &
SERVER_PID=$!
sleep 2
# 2. Run the load test — default: 20s, 4 writers, 2 KB docs
./load_test [duration_seconds] [writer_threads] [doc_bytes]
# Example — 30s with 8 writers:
./load_test 30 8 2048
# 3. Stop the server
kill $SERVER_PID
# 4. Inspect eviction events
grep -E "Eviction|MEMORY_" /tmp/smartbotic-loadtest/server.log
Sample output from a successful run (32 MB cap, 20s, 4 writers, 2 KB docs):
[t=18504ms] pressure= hard 84% mem=27584KB live= 5276 evicted= 41580 inserts= 46856 fails= 0
=== Summary ===
Duration: 20162ms
Successful inserts: 51444 (2551 ops/s)
Failed (after retries): 0
Pressure timeline:
normal: 1.5s
soft: 5.0s
hard: 9.0s
emergency: 2.0s
Transitions: 19
Verdict: PASS — client-side retry absorbed all transient errors
| Signal | What it means |
|---|---|
Eviction chunk: N docs evicted, X bytes freed |
T4 chunked eviction is working |
Eviction: nothing evictable this pass, backing off |
T4 hot-write floor is protecting in-flight upserts |
Emitted MEMORY_PRESSURE_HIGH |
T10 edge-triggered event fired |
Insert rejected: memory pressure emergency |
T7 admission control engaged |
Client::insert ...; retrying in Nms (attempt K/5) |
T11 client retry kicked in |
Successful inserts: N == attempts, Failed: 0 |
No writes lost under pressure |
Edit config.json:
hot_write_floor_ms to 500 ms so eviction can actually drop recent writeseviction_chunk_pause_ms to 200 msmemory_emergency_percent to 99max_memory_mb to 256 to see if the chunked approach still works at scale