add a filter query cache 512mb that stores already decoded recent query results
this should improve performance noticeably for typical kind 1 client queries
This commit is contained in:
@@ -77,9 +77,11 @@
|
|||||||
"Bash(docker run:*)",
|
"Bash(docker run:*)",
|
||||||
"Bash(docker inspect:*)",
|
"Bash(docker inspect:*)",
|
||||||
"Bash(./run-benchmark-clean.sh:*)",
|
"Bash(./run-benchmark-clean.sh:*)",
|
||||||
"Bash(cd:*)"
|
"Bash(cd:*)",
|
||||||
|
"Bash(CGO_ENABLED=0 timeout 180 go build:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
}
|
},
|
||||||
|
"outputStyle": "Explanatory"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,10 @@ type C struct {
|
|||||||
NIP43InviteExpiry time.Duration `env:"ORLY_NIP43_INVITE_EXPIRY" default:"24h" usage:"how long invite codes remain valid"`
|
NIP43InviteExpiry time.Duration `env:"ORLY_NIP43_INVITE_EXPIRY" default:"24h" usage:"how long invite codes remain valid"`
|
||||||
|
|
||||||
// Database configuration
|
// Database configuration
|
||||||
DBType string `env:"ORLY_DB_TYPE" default:"badger" usage:"database backend to use: badger or dgraph"`
|
DBType string `env:"ORLY_DB_TYPE" default:"badger" usage:"database backend to use: badger or dgraph"`
|
||||||
DgraphURL string `env:"ORLY_DGRAPH_URL" default:"localhost:9080" usage:"dgraph gRPC endpoint address (only used when ORLY_DB_TYPE=dgraph)"`
|
DgraphURL string `env:"ORLY_DGRAPH_URL" default:"localhost:9080" usage:"dgraph gRPC endpoint address (only used when ORLY_DB_TYPE=dgraph)"`
|
||||||
|
QueryCacheSizeMB int `env:"ORLY_QUERY_CACHE_SIZE_MB" default:"512" usage:"query cache size in MB (caches database query results for faster REQ responses)"`
|
||||||
|
QueryCacheMaxAge string `env:"ORLY_QUERY_CACHE_MAX_AGE" default:"5m" usage:"maximum age for cached query results (e.g., 5m, 10m, 1h)"`
|
||||||
|
|
||||||
// TLS configuration
|
// TLS configuration
|
||||||
TLSDomains []string `env:"ORLY_TLS_DOMAINS" usage:"comma-separated list of domains to respond to for TLS"`
|
TLSDomains []string `env:"ORLY_TLS_DOMAINS" usage:"comma-separated list of domains to respond to for TLS"`
|
||||||
|
|||||||
@@ -1,140 +0,0 @@
|
|||||||
================================================================
|
|
||||||
NOSTR RELAY BENCHMARK AGGREGATE REPORT
|
|
||||||
================================================================
|
|
||||||
Generated: 2025-09-20T11:04:39+00:00
|
|
||||||
Benchmark Configuration:
|
|
||||||
Events per test: 10000
|
|
||||||
Concurrent workers: 8
|
|
||||||
Test duration: 60s
|
|
||||||
|
|
||||||
Relays tested: 6
|
|
||||||
|
|
||||||
================================================================
|
|
||||||
SUMMARY BY RELAY
|
|
||||||
================================================================
|
|
||||||
|
|
||||||
Relay: next-orly
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1035.42
|
|
||||||
Events/sec: 659.20
|
|
||||||
Events/sec: 1094.56
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 470.069µs
|
|
||||||
Bottom 10% Avg Latency: 750.491µs
|
|
||||||
Avg Latency: 190.573µs
|
|
||||||
P95 Latency: 693.101µs
|
|
||||||
P95 Latency: 289.761µs
|
|
||||||
P95 Latency: 22.450848ms
|
|
||||||
|
|
||||||
Relay: khatru-sqlite
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1105.61
|
|
||||||
Events/sec: 624.87
|
|
||||||
Events/sec: 1070.10
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 458.035µs
|
|
||||||
Bottom 10% Avg Latency: 702.193µs
|
|
||||||
Avg Latency: 193.997µs
|
|
||||||
P95 Latency: 660.608µs
|
|
||||||
P95 Latency: 302.666µs
|
|
||||||
P95 Latency: 23.653412ms
|
|
||||||
|
|
||||||
Relay: khatru-badger
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1040.11
|
|
||||||
Events/sec: 663.14
|
|
||||||
Events/sec: 1065.58
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 454.784µs
|
|
||||||
Bottom 10% Avg Latency: 706.219µs
|
|
||||||
Avg Latency: 193.914µs
|
|
||||||
P95 Latency: 654.637µs
|
|
||||||
P95 Latency: 296.525µs
|
|
||||||
P95 Latency: 21.642655ms
|
|
||||||
|
|
||||||
Relay: relayer-basic
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1104.88
|
|
||||||
Events/sec: 642.17
|
|
||||||
Events/sec: 1079.27
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 433.89µs
|
|
||||||
Bottom 10% Avg Latency: 653.813µs
|
|
||||||
Avg Latency: 186.306µs
|
|
||||||
P95 Latency: 617.868µs
|
|
||||||
P95 Latency: 279.192µs
|
|
||||||
P95 Latency: 21.247322ms
|
|
||||||
|
|
||||||
Relay: strfry
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1090.49
|
|
||||||
Events/sec: 652.03
|
|
||||||
Events/sec: 1098.57
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 448.058µs
|
|
||||||
Bottom 10% Avg Latency: 729.464µs
|
|
||||||
Avg Latency: 189.06µs
|
|
||||||
P95 Latency: 667.141µs
|
|
||||||
P95 Latency: 290.433µs
|
|
||||||
P95 Latency: 20.822884ms
|
|
||||||
|
|
||||||
Relay: nostr-rs-relay
|
|
||||||
----------------------------------------
|
|
||||||
Status: COMPLETED
|
|
||||||
Events/sec: 1123.91
|
|
||||||
Events/sec: 647.62
|
|
||||||
Events/sec: 1033.64
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Avg Latency: 416.753µs
|
|
||||||
Bottom 10% Avg Latency: 638.318µs
|
|
||||||
Avg Latency: 185.217µs
|
|
||||||
P95 Latency: 597.338µs
|
|
||||||
P95 Latency: 273.191µs
|
|
||||||
P95 Latency: 22.416221ms
|
|
||||||
|
|
||||||
|
|
||||||
================================================================
|
|
||||||
DETAILED RESULTS
|
|
||||||
================================================================
|
|
||||||
|
|
||||||
Individual relay reports are available in:
|
|
||||||
- /reports/run_20250920_101521/khatru-badger_results.txt
|
|
||||||
- /reports/run_20250920_101521/khatru-sqlite_results.txt
|
|
||||||
- /reports/run_20250920_101521/next-orly_results.txt
|
|
||||||
- /reports/run_20250920_101521/nostr-rs-relay_results.txt
|
|
||||||
- /reports/run_20250920_101521/relayer-basic_results.txt
|
|
||||||
- /reports/run_20250920_101521/strfry_results.txt
|
|
||||||
|
|
||||||
================================================================
|
|
||||||
BENCHMARK COMPARISON TABLE
|
|
||||||
================================================================
|
|
||||||
|
|
||||||
Relay Status Peak Tput/s Avg Latency Success Rate
|
|
||||||
---- ------ ----------- ----------- ------------
|
|
||||||
next-orly OK 1035.42 470.069µs 100.0%
|
|
||||||
khatru-sqlite OK 1105.61 458.035µs 100.0%
|
|
||||||
khatru-badger OK 1040.11 454.784µs 100.0%
|
|
||||||
relayer-basic OK 1104.88 433.89µs 100.0%
|
|
||||||
strfry OK 1090.49 448.058µs 100.0%
|
|
||||||
nostr-rs-relay OK 1123.91 416.753µs 100.0%
|
|
||||||
|
|
||||||
================================================================
|
|
||||||
End of Report
|
|
||||||
================================================================
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_khatru-badger_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758364309339505ℹ️/tmp/benchmark_khatru-badger_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758364309340007ℹ️/tmp/benchmark_khatru-badger_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758364309340039ℹ️/tmp/benchmark_khatru-badger_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758364309340327ℹ️(*types.Uint32)(0xc000147840)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758364309340465ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.614321551s
|
|
||||||
Events/sec: 1040.11
|
|
||||||
Avg latency: 454.784µs
|
|
||||||
P90 latency: 596.266µs
|
|
||||||
P95 latency: 654.637µs
|
|
||||||
P99 latency: 844.569µs
|
|
||||||
Bottom 10% Avg latency: 706.219µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 136.444875ms
|
|
||||||
Burst completed: 1000 events in 141.806497ms
|
|
||||||
Burst completed: 1000 events in 168.991278ms
|
|
||||||
Burst completed: 1000 events in 167.713425ms
|
|
||||||
Burst completed: 1000 events in 162.89698ms
|
|
||||||
Burst completed: 1000 events in 157.775164ms
|
|
||||||
Burst completed: 1000 events in 166.476709ms
|
|
||||||
Burst completed: 1000 events in 161.742632ms
|
|
||||||
Burst completed: 1000 events in 162.138977ms
|
|
||||||
Burst completed: 1000 events in 156.657194ms
|
|
||||||
Burst test completed: 10000 events in 15.07982611s
|
|
||||||
Events/sec: 663.14
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 44.903267299s
|
|
||||||
Combined ops/sec: 222.70
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3166 queries in 1m0.104195004s
|
|
||||||
Queries/sec: 52.68
|
|
||||||
Avg query latency: 125.847553ms
|
|
||||||
P95 query latency: 148.109766ms
|
|
||||||
P99 query latency: 212.054697ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11366 operations (1366 queries, 10000 writes) in 1m0.127232573s
|
|
||||||
Operations/sec: 189.03
|
|
||||||
Avg latency: 16.671438ms
|
|
||||||
Avg query latency: 134.993072ms
|
|
||||||
Avg write latency: 508.703µs
|
|
||||||
P95 latency: 133.755996ms
|
|
||||||
P99 latency: 152.790563ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.384548186s
|
|
||||||
Events/sec: 1065.58
|
|
||||||
Avg latency: 566.375µs
|
|
||||||
P90 latency: 738.377µs
|
|
||||||
P95 latency: 839.679µs
|
|
||||||
P99 latency: 1.131084ms
|
|
||||||
Bottom 10% Avg latency: 1.312791ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 166.832259ms
|
|
||||||
Burst completed: 1000 events in 175.061575ms
|
|
||||||
Burst completed: 1000 events in 168.897493ms
|
|
||||||
Burst completed: 1000 events in 167.584171ms
|
|
||||||
Burst completed: 1000 events in 178.212526ms
|
|
||||||
Burst completed: 1000 events in 202.208945ms
|
|
||||||
Burst completed: 1000 events in 154.130024ms
|
|
||||||
Burst completed: 1000 events in 168.817721ms
|
|
||||||
Burst completed: 1000 events in 153.032223ms
|
|
||||||
Burst completed: 1000 events in 154.799008ms
|
|
||||||
Burst test completed: 10000 events in 15.449161726s
|
|
||||||
Events/sec: 647.28
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4582 reads in 1m0.037041762s
|
|
||||||
Combined ops/sec: 159.60
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 959 queries in 1m0.42440735s
|
|
||||||
Queries/sec: 15.87
|
|
||||||
Avg query latency: 418.846875ms
|
|
||||||
P95 query latency: 473.089327ms
|
|
||||||
P99 query latency: 650.467474ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10484 operations (484 queries, 10000 writes) in 1m0.283590079s
|
|
||||||
Operations/sec: 173.91
|
|
||||||
Avg latency: 17.921964ms
|
|
||||||
Avg query latency: 381.041592ms
|
|
||||||
Avg write latency: 346.974µs
|
|
||||||
P95 latency: 1.269749ms
|
|
||||||
P99 latency: 399.015222ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.614321551s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1040.11
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 118 MB
|
|
||||||
Avg Latency: 454.784µs
|
|
||||||
P90 Latency: 596.266µs
|
|
||||||
P95 Latency: 654.637µs
|
|
||||||
P99 Latency: 844.569µs
|
|
||||||
Bottom 10% Avg Latency: 706.219µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.07982611s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 663.14
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 162 MB
|
|
||||||
Avg Latency: 193.914µs
|
|
||||||
P90 Latency: 255.617µs
|
|
||||||
P95 Latency: 296.525µs
|
|
||||||
P99 Latency: 451.81µs
|
|
||||||
Bottom 10% Avg Latency: 343.222µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 44.903267299s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 222.70
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 121 MB
|
|
||||||
Avg Latency: 9.145633ms
|
|
||||||
P90 Latency: 19.946513ms
|
|
||||||
P95 Latency: 21.642655ms
|
|
||||||
P99 Latency: 23.951572ms
|
|
||||||
Bottom 10% Avg Latency: 21.861602ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.104195004s
|
|
||||||
Total Events: 3166
|
|
||||||
Events/sec: 52.68
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 188 MB
|
|
||||||
Avg Latency: 125.847553ms
|
|
||||||
P90 Latency: 140.664966ms
|
|
||||||
P95 Latency: 148.109766ms
|
|
||||||
P99 Latency: 212.054697ms
|
|
||||||
Bottom 10% Avg Latency: 164.089129ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.127232573s
|
|
||||||
Total Events: 11366
|
|
||||||
Events/sec: 189.03
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 112 MB
|
|
||||||
Avg Latency: 16.671438ms
|
|
||||||
P90 Latency: 122.627849ms
|
|
||||||
P95 Latency: 133.755996ms
|
|
||||||
P99 Latency: 152.790563ms
|
|
||||||
Bottom 10% Avg Latency: 138.087104ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.384548186s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1065.58
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 566.375µs
|
|
||||||
P90 Latency: 738.377µs
|
|
||||||
P95 Latency: 839.679µs
|
|
||||||
P99 Latency: 1.131084ms
|
|
||||||
Bottom 10% Avg Latency: 1.312791ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.449161726s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 647.28
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 165 MB
|
|
||||||
Avg Latency: 186.353µs
|
|
||||||
P90 Latency: 243.413µs
|
|
||||||
P95 Latency: 283.06µs
|
|
||||||
P99 Latency: 440.76µs
|
|
||||||
Bottom 10% Avg Latency: 324.151µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.037041762s
|
|
||||||
Total Events: 9582
|
|
||||||
Events/sec: 159.60
|
|
||||||
Success Rate: 95.8%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 138 MB
|
|
||||||
Avg Latency: 16.358228ms
|
|
||||||
P90 Latency: 37.654373ms
|
|
||||||
P95 Latency: 40.578604ms
|
|
||||||
P99 Latency: 46.331181ms
|
|
||||||
Bottom 10% Avg Latency: 41.76124ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.42440735s
|
|
||||||
Total Events: 959
|
|
||||||
Events/sec: 15.87
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 110 MB
|
|
||||||
Avg Latency: 418.846875ms
|
|
||||||
P90 Latency: 448.809017ms
|
|
||||||
P95 Latency: 473.089327ms
|
|
||||||
P99 Latency: 650.467474ms
|
|
||||||
Bottom 10% Avg Latency: 518.112626ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.283590079s
|
|
||||||
Total Events: 10484
|
|
||||||
Events/sec: 173.91
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 205 MB
|
|
||||||
Avg Latency: 17.921964ms
|
|
||||||
P90 Latency: 582.319µs
|
|
||||||
P95 Latency: 1.269749ms
|
|
||||||
P99 Latency: 399.015222ms
|
|
||||||
Bottom 10% Avg Latency: 176.257001ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_khatru-badger_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_khatru-badger_8/benchmark_report.adoc
|
|
||||||
1758364794792663ℹ️/tmp/benchmark_khatru-badger_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758364796617126ℹ️/tmp/benchmark_khatru-badger_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758364796621659ℹ️/tmp/benchmark_khatru-badger_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: khatru-badger
|
|
||||||
RELAY_URL: ws://khatru-badger:3334
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T10:39:56+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_khatru-sqlite_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758363814412229ℹ️/tmp/benchmark_khatru-sqlite_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758363814412803ℹ️/tmp/benchmark_khatru-sqlite_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758363814412840ℹ️/tmp/benchmark_khatru-sqlite_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758363814413123ℹ️(*types.Uint32)(0xc0001ea00c)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758363814413200ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.044789549s
|
|
||||||
Events/sec: 1105.61
|
|
||||||
Avg latency: 458.035µs
|
|
||||||
P90 latency: 601.736µs
|
|
||||||
P95 latency: 660.608µs
|
|
||||||
P99 latency: 844.108µs
|
|
||||||
Bottom 10% Avg latency: 702.193µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 146.610877ms
|
|
||||||
Burst completed: 1000 events in 179.229665ms
|
|
||||||
Burst completed: 1000 events in 157.096919ms
|
|
||||||
Burst completed: 1000 events in 164.796374ms
|
|
||||||
Burst completed: 1000 events in 188.464354ms
|
|
||||||
Burst completed: 1000 events in 196.529596ms
|
|
||||||
Burst completed: 1000 events in 169.425581ms
|
|
||||||
Burst completed: 1000 events in 147.99354ms
|
|
||||||
Burst completed: 1000 events in 157.996252ms
|
|
||||||
Burst completed: 1000 events in 167.299262ms
|
|
||||||
Burst test completed: 10000 events in 16.003207139s
|
|
||||||
Events/sec: 624.87
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 46.924555793s
|
|
||||||
Combined ops/sec: 213.11
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3052 queries in 1m0.102264s
|
|
||||||
Queries/sec: 50.78
|
|
||||||
Avg query latency: 128.464192ms
|
|
||||||
P95 query latency: 148.086431ms
|
|
||||||
P99 query latency: 219.275394ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11296 operations (1296 queries, 10000 writes) in 1m0.108871986s
|
|
||||||
Operations/sec: 187.93
|
|
||||||
Avg latency: 16.71621ms
|
|
||||||
Avg query latency: 142.320434ms
|
|
||||||
Avg write latency: 437.903µs
|
|
||||||
P95 latency: 141.357185ms
|
|
||||||
P99 latency: 163.50992ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.344884331s
|
|
||||||
Events/sec: 1070.10
|
|
||||||
Avg latency: 578.453µs
|
|
||||||
P90 latency: 742.585µs
|
|
||||||
P95 latency: 849.679µs
|
|
||||||
P99 latency: 1.122058ms
|
|
||||||
Bottom 10% Avg latency: 1.362355ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 185.472655ms
|
|
||||||
Burst completed: 1000 events in 194.135516ms
|
|
||||||
Burst completed: 1000 events in 176.056931ms
|
|
||||||
Burst completed: 1000 events in 161.500315ms
|
|
||||||
Burst completed: 1000 events in 157.673837ms
|
|
||||||
Burst completed: 1000 events in 167.130208ms
|
|
||||||
Burst completed: 1000 events in 182.164655ms
|
|
||||||
Burst completed: 1000 events in 156.589581ms
|
|
||||||
Burst completed: 1000 events in 154.419949ms
|
|
||||||
Burst completed: 1000 events in 158.445927ms
|
|
||||||
Burst test completed: 10000 events in 15.587711126s
|
|
||||||
Events/sec: 641.53
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4405 reads in 1m0.043842569s
|
|
||||||
Combined ops/sec: 156.64
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 915 queries in 1m0.3452177s
|
|
||||||
Queries/sec: 15.16
|
|
||||||
Avg query latency: 435.125142ms
|
|
||||||
P95 query latency: 520.311963ms
|
|
||||||
P99 query latency: 618.85899ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10489 operations (489 queries, 10000 writes) in 1m0.27235761s
|
|
||||||
Operations/sec: 174.03
|
|
||||||
Avg latency: 18.043774ms
|
|
||||||
Avg query latency: 379.681531ms
|
|
||||||
Avg write latency: 359.688µs
|
|
||||||
P95 latency: 1.316628ms
|
|
||||||
P99 latency: 400.223248ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.044789549s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1105.61
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 144 MB
|
|
||||||
Avg Latency: 458.035µs
|
|
||||||
P90 Latency: 601.736µs
|
|
||||||
P95 Latency: 660.608µs
|
|
||||||
P99 Latency: 844.108µs
|
|
||||||
Bottom 10% Avg Latency: 702.193µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 16.003207139s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 624.87
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 89 MB
|
|
||||||
Avg Latency: 193.997µs
|
|
||||||
P90 Latency: 261.969µs
|
|
||||||
P95 Latency: 302.666µs
|
|
||||||
P99 Latency: 431.933µs
|
|
||||||
Bottom 10% Avg Latency: 334.383µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 46.924555793s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 213.11
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 96 MB
|
|
||||||
Avg Latency: 9.781737ms
|
|
||||||
P90 Latency: 21.91971ms
|
|
||||||
P95 Latency: 23.653412ms
|
|
||||||
P99 Latency: 27.511972ms
|
|
||||||
Bottom 10% Avg Latency: 24.396695ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.102264s
|
|
||||||
Total Events: 3052
|
|
||||||
Events/sec: 50.78
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 209 MB
|
|
||||||
Avg Latency: 128.464192ms
|
|
||||||
P90 Latency: 142.195039ms
|
|
||||||
P95 Latency: 148.086431ms
|
|
||||||
P99 Latency: 219.275394ms
|
|
||||||
Bottom 10% Avg Latency: 162.874217ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.108871986s
|
|
||||||
Total Events: 11296
|
|
||||||
Events/sec: 187.93
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 159 MB
|
|
||||||
Avg Latency: 16.71621ms
|
|
||||||
P90 Latency: 127.287246ms
|
|
||||||
P95 Latency: 141.357185ms
|
|
||||||
P99 Latency: 163.50992ms
|
|
||||||
Bottom 10% Avg Latency: 145.199189ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.344884331s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1070.10
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 578.453µs
|
|
||||||
P90 Latency: 742.585µs
|
|
||||||
P95 Latency: 849.679µs
|
|
||||||
P99 Latency: 1.122058ms
|
|
||||||
Bottom 10% Avg Latency: 1.362355ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.587711126s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 641.53
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 141 MB
|
|
||||||
Avg Latency: 190.235µs
|
|
||||||
P90 Latency: 254.795µs
|
|
||||||
P95 Latency: 290.563µs
|
|
||||||
P99 Latency: 437.323µs
|
|
||||||
Bottom 10% Avg Latency: 328.752µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.043842569s
|
|
||||||
Total Events: 9405
|
|
||||||
Events/sec: 156.64
|
|
||||||
Success Rate: 94.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 105 MB
|
|
||||||
Avg Latency: 16.852438ms
|
|
||||||
P90 Latency: 39.677855ms
|
|
||||||
P95 Latency: 42.553634ms
|
|
||||||
P99 Latency: 48.262077ms
|
|
||||||
Bottom 10% Avg Latency: 43.994063ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.3452177s
|
|
||||||
Total Events: 915
|
|
||||||
Events/sec: 15.16
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 157 MB
|
|
||||||
Avg Latency: 435.125142ms
|
|
||||||
P90 Latency: 482.304439ms
|
|
||||||
P95 Latency: 520.311963ms
|
|
||||||
P99 Latency: 618.85899ms
|
|
||||||
Bottom 10% Avg Latency: 545.670939ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.27235761s
|
|
||||||
Total Events: 10489
|
|
||||||
Events/sec: 174.03
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 132 MB
|
|
||||||
Avg Latency: 18.043774ms
|
|
||||||
P90 Latency: 583.962µs
|
|
||||||
P95 Latency: 1.316628ms
|
|
||||||
P99 Latency: 400.223248ms
|
|
||||||
Bottom 10% Avg Latency: 177.440946ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_khatru-sqlite_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_khatru-sqlite_8/benchmark_report.adoc
|
|
||||||
1758364302230610ℹ️/tmp/benchmark_khatru-sqlite_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758364304057942ℹ️/tmp/benchmark_khatru-sqlite_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758364304063521ℹ️/tmp/benchmark_khatru-sqlite_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: khatru-sqlite
|
|
||||||
RELAY_URL: ws://khatru-sqlite:3334
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T10:31:44+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_next-orly_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758363321263384ℹ️/tmp/benchmark_next-orly_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758363321263864ℹ️/tmp/benchmark_next-orly_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758363321263887ℹ️/tmp/benchmark_next-orly_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758363321264128ℹ️(*types.Uint32)(0xc0001f7ffc)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758363321264177ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.657904043s
|
|
||||||
Events/sec: 1035.42
|
|
||||||
Avg latency: 470.069µs
|
|
||||||
P90 latency: 628.167µs
|
|
||||||
P95 latency: 693.101µs
|
|
||||||
P99 latency: 922.357µs
|
|
||||||
Bottom 10% Avg latency: 750.491µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 175.034134ms
|
|
||||||
Burst completed: 1000 events in 150.401771ms
|
|
||||||
Burst completed: 1000 events in 168.992305ms
|
|
||||||
Burst completed: 1000 events in 179.447581ms
|
|
||||||
Burst completed: 1000 events in 165.602457ms
|
|
||||||
Burst completed: 1000 events in 178.649561ms
|
|
||||||
Burst completed: 1000 events in 195.002303ms
|
|
||||||
Burst completed: 1000 events in 168.970954ms
|
|
||||||
Burst completed: 1000 events in 150.818413ms
|
|
||||||
Burst completed: 1000 events in 185.285662ms
|
|
||||||
Burst test completed: 10000 events in 15.169978801s
|
|
||||||
Events/sec: 659.20
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 45.597478865s
|
|
||||||
Combined ops/sec: 219.31
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3151 queries in 1m0.067849757s
|
|
||||||
Queries/sec: 52.46
|
|
||||||
Avg query latency: 126.38548ms
|
|
||||||
P95 query latency: 149.976367ms
|
|
||||||
P99 query latency: 205.807461ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11325 operations (1325 queries, 10000 writes) in 1m0.081967157s
|
|
||||||
Operations/sec: 188.49
|
|
||||||
Avg latency: 16.694154ms
|
|
||||||
Avg query latency: 139.524748ms
|
|
||||||
Avg write latency: 419.1µs
|
|
||||||
P95 latency: 138.688202ms
|
|
||||||
P99 latency: 158.824742ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.136097148s
|
|
||||||
Events/sec: 1094.56
|
|
||||||
Avg latency: 510.7µs
|
|
||||||
P90 latency: 636.763µs
|
|
||||||
P95 latency: 705.564µs
|
|
||||||
P99 latency: 922.777µs
|
|
||||||
Bottom 10% Avg latency: 1.094965ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 176.337148ms
|
|
||||||
Burst completed: 1000 events in 177.351251ms
|
|
||||||
Burst completed: 1000 events in 181.515292ms
|
|
||||||
Burst completed: 1000 events in 164.043866ms
|
|
||||||
Burst completed: 1000 events in 152.697196ms
|
|
||||||
Burst completed: 1000 events in 144.231922ms
|
|
||||||
Burst completed: 1000 events in 162.606659ms
|
|
||||||
Burst completed: 1000 events in 137.485182ms
|
|
||||||
Burst completed: 1000 events in 163.19487ms
|
|
||||||
Burst completed: 1000 events in 147.900339ms
|
|
||||||
Burst test completed: 10000 events in 15.514130113s
|
|
||||||
Events/sec: 644.57
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4489 reads in 1m0.036174989s
|
|
||||||
Combined ops/sec: 158.05
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 900 queries in 1m0.304636826s
|
|
||||||
Queries/sec: 14.92
|
|
||||||
Avg query latency: 444.57989ms
|
|
||||||
P95 query latency: 547.598358ms
|
|
||||||
P99 query latency: 660.926147ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10462 operations (462 queries, 10000 writes) in 1m0.362856212s
|
|
||||||
Operations/sec: 173.32
|
|
||||||
Avg latency: 17.808607ms
|
|
||||||
Avg query latency: 395.594177ms
|
|
||||||
Avg write latency: 354.914µs
|
|
||||||
P95 latency: 1.221657ms
|
|
||||||
P99 latency: 411.642669ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.657904043s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1035.42
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 144 MB
|
|
||||||
Avg Latency: 470.069µs
|
|
||||||
P90 Latency: 628.167µs
|
|
||||||
P95 Latency: 693.101µs
|
|
||||||
P99 Latency: 922.357µs
|
|
||||||
Bottom 10% Avg Latency: 750.491µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.169978801s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 659.20
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 135 MB
|
|
||||||
Avg Latency: 190.573µs
|
|
||||||
P90 Latency: 252.701µs
|
|
||||||
P95 Latency: 289.761µs
|
|
||||||
P99 Latency: 408.147µs
|
|
||||||
Bottom 10% Avg Latency: 316.797µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 45.597478865s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 219.31
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 119 MB
|
|
||||||
Avg Latency: 9.381158ms
|
|
||||||
P90 Latency: 20.487026ms
|
|
||||||
P95 Latency: 22.450848ms
|
|
||||||
P99 Latency: 24.696325ms
|
|
||||||
Bottom 10% Avg Latency: 22.632933ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.067849757s
|
|
||||||
Total Events: 3151
|
|
||||||
Events/sec: 52.46
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 145 MB
|
|
||||||
Avg Latency: 126.38548ms
|
|
||||||
P90 Latency: 142.39268ms
|
|
||||||
P95 Latency: 149.976367ms
|
|
||||||
P99 Latency: 205.807461ms
|
|
||||||
Bottom 10% Avg Latency: 162.636454ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.081967157s
|
|
||||||
Total Events: 11325
|
|
||||||
Events/sec: 188.49
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 194 MB
|
|
||||||
Avg Latency: 16.694154ms
|
|
||||||
P90 Latency: 125.314618ms
|
|
||||||
P95 Latency: 138.688202ms
|
|
||||||
P99 Latency: 158.824742ms
|
|
||||||
Bottom 10% Avg Latency: 142.699977ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.136097148s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1094.56
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 510.7µs
|
|
||||||
P90 Latency: 636.763µs
|
|
||||||
P95 Latency: 705.564µs
|
|
||||||
P99 Latency: 922.777µs
|
|
||||||
Bottom 10% Avg Latency: 1.094965ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.514130113s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 644.57
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 138 MB
|
|
||||||
Avg Latency: 230.062µs
|
|
||||||
P90 Latency: 316.624µs
|
|
||||||
P95 Latency: 389.882µs
|
|
||||||
P99 Latency: 859.548µs
|
|
||||||
Bottom 10% Avg Latency: 529.836µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.036174989s
|
|
||||||
Total Events: 9489
|
|
||||||
Events/sec: 158.05
|
|
||||||
Success Rate: 94.9%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 182 MB
|
|
||||||
Avg Latency: 16.56372ms
|
|
||||||
P90 Latency: 38.24931ms
|
|
||||||
P95 Latency: 41.187306ms
|
|
||||||
P99 Latency: 46.02529ms
|
|
||||||
Bottom 10% Avg Latency: 42.131189ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.304636826s
|
|
||||||
Total Events: 900
|
|
||||||
Events/sec: 14.92
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 141 MB
|
|
||||||
Avg Latency: 444.57989ms
|
|
||||||
P90 Latency: 490.730651ms
|
|
||||||
P95 Latency: 547.598358ms
|
|
||||||
P99 Latency: 660.926147ms
|
|
||||||
Bottom 10% Avg Latency: 563.628707ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.362856212s
|
|
||||||
Total Events: 10462
|
|
||||||
Events/sec: 173.32
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 152 MB
|
|
||||||
Avg Latency: 17.808607ms
|
|
||||||
P90 Latency: 631.703µs
|
|
||||||
P95 Latency: 1.221657ms
|
|
||||||
P99 Latency: 411.642669ms
|
|
||||||
Bottom 10% Avg Latency: 175.052418ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_next-orly_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_next-orly_8/benchmark_report.adoc
|
|
||||||
1758363807245770ℹ️/tmp/benchmark_next-orly_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758363809118416ℹ️/tmp/benchmark_next-orly_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758363809123697ℹ️/tmp/benchmark_next-orly_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: next-orly
|
|
||||||
RELAY_URL: ws://next-orly:8080
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T10:23:29+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_nostr-rs-relay_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758365785928076ℹ️/tmp/benchmark_nostr-rs-relay_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758365785929028ℹ️/tmp/benchmark_nostr-rs-relay_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758365785929097ℹ️/tmp/benchmark_nostr-rs-relay_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758365785929509ℹ️(*types.Uint32)(0xc0001c820c)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758365785929573ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 8.897492256s
|
|
||||||
Events/sec: 1123.91
|
|
||||||
Avg latency: 416.753µs
|
|
||||||
P90 latency: 546.351µs
|
|
||||||
P95 latency: 597.338µs
|
|
||||||
P99 latency: 760.549µs
|
|
||||||
Bottom 10% Avg latency: 638.318µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 158.263016ms
|
|
||||||
Burst completed: 1000 events in 181.558983ms
|
|
||||||
Burst completed: 1000 events in 155.219861ms
|
|
||||||
Burst completed: 1000 events in 183.834156ms
|
|
||||||
Burst completed: 1000 events in 192.398437ms
|
|
||||||
Burst completed: 1000 events in 176.450074ms
|
|
||||||
Burst completed: 1000 events in 175.050138ms
|
|
||||||
Burst completed: 1000 events in 178.883047ms
|
|
||||||
Burst completed: 1000 events in 180.74321ms
|
|
||||||
Burst completed: 1000 events in 169.39146ms
|
|
||||||
Burst test completed: 10000 events in 15.441062872s
|
|
||||||
Events/sec: 647.62
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 45.847091984s
|
|
||||||
Combined ops/sec: 218.12
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3229 queries in 1m0.085047549s
|
|
||||||
Queries/sec: 53.74
|
|
||||||
Avg query latency: 123.209617ms
|
|
||||||
P95 query latency: 141.745618ms
|
|
||||||
P99 query latency: 154.527843ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11298 operations (1298 queries, 10000 writes) in 1m0.096751583s
|
|
||||||
Operations/sec: 188.00
|
|
||||||
Avg latency: 16.447175ms
|
|
||||||
Avg query latency: 139.791065ms
|
|
||||||
Avg write latency: 437.138µs
|
|
||||||
P95 latency: 137.879538ms
|
|
||||||
P99 latency: 162.020385ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.674593819s
|
|
||||||
Events/sec: 1033.64
|
|
||||||
Avg latency: 541.545µs
|
|
||||||
P90 latency: 693.862µs
|
|
||||||
P95 latency: 775.757µs
|
|
||||||
P99 latency: 1.05005ms
|
|
||||||
Bottom 10% Avg latency: 1.219386ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 168.056064ms
|
|
||||||
Burst completed: 1000 events in 159.819647ms
|
|
||||||
Burst completed: 1000 events in 147.500264ms
|
|
||||||
Burst completed: 1000 events in 159.150392ms
|
|
||||||
Burst completed: 1000 events in 149.954829ms
|
|
||||||
Burst completed: 1000 events in 138.082938ms
|
|
||||||
Burst completed: 1000 events in 157.234213ms
|
|
||||||
Burst completed: 1000 events in 158.468955ms
|
|
||||||
Burst completed: 1000 events in 144.346047ms
|
|
||||||
Burst completed: 1000 events in 154.930576ms
|
|
||||||
Burst test completed: 10000 events in 15.646785427s
|
|
||||||
Events/sec: 639.11
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4415 reads in 1m0.02899167s
|
|
||||||
Combined ops/sec: 156.84
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 890 queries in 1m0.279192867s
|
|
||||||
Queries/sec: 14.76
|
|
||||||
Avg query latency: 448.809547ms
|
|
||||||
P95 query latency: 607.28509ms
|
|
||||||
P99 query latency: 786.387053ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10469 operations (469 queries, 10000 writes) in 1m0.190785048s
|
|
||||||
Operations/sec: 173.93
|
|
||||||
Avg latency: 17.73903ms
|
|
||||||
Avg query latency: 388.59336ms
|
|
||||||
Avg write latency: 345.962µs
|
|
||||||
P95 latency: 1.158136ms
|
|
||||||
P99 latency: 407.947907ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 8.897492256s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1123.91
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 132 MB
|
|
||||||
Avg Latency: 416.753µs
|
|
||||||
P90 Latency: 546.351µs
|
|
||||||
P95 Latency: 597.338µs
|
|
||||||
P99 Latency: 760.549µs
|
|
||||||
Bottom 10% Avg Latency: 638.318µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.441062872s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 647.62
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 104 MB
|
|
||||||
Avg Latency: 185.217µs
|
|
||||||
P90 Latency: 241.64µs
|
|
||||||
P95 Latency: 273.191µs
|
|
||||||
P99 Latency: 412.897µs
|
|
||||||
Bottom 10% Avg Latency: 306.752µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 45.847091984s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 218.12
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 96 MB
|
|
||||||
Avg Latency: 9.446215ms
|
|
||||||
P90 Latency: 20.522135ms
|
|
||||||
P95 Latency: 22.416221ms
|
|
||||||
P99 Latency: 24.696283ms
|
|
||||||
Bottom 10% Avg Latency: 22.59535ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.085047549s
|
|
||||||
Total Events: 3229
|
|
||||||
Events/sec: 53.74
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 175 MB
|
|
||||||
Avg Latency: 123.209617ms
|
|
||||||
P90 Latency: 137.629898ms
|
|
||||||
P95 Latency: 141.745618ms
|
|
||||||
P99 Latency: 154.527843ms
|
|
||||||
Bottom 10% Avg Latency: 145.245967ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.096751583s
|
|
||||||
Total Events: 11298
|
|
||||||
Events/sec: 188.00
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 181 MB
|
|
||||||
Avg Latency: 16.447175ms
|
|
||||||
P90 Latency: 123.920421ms
|
|
||||||
P95 Latency: 137.879538ms
|
|
||||||
P99 Latency: 162.020385ms
|
|
||||||
Bottom 10% Avg Latency: 142.654147ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.674593819s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1033.64
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 541.545µs
|
|
||||||
P90 Latency: 693.862µs
|
|
||||||
P95 Latency: 775.757µs
|
|
||||||
P99 Latency: 1.05005ms
|
|
||||||
Bottom 10% Avg Latency: 1.219386ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.646785427s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 639.11
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 146 MB
|
|
||||||
Avg Latency: 331.896µs
|
|
||||||
P90 Latency: 520.511µs
|
|
||||||
P95 Latency: 864.486µs
|
|
||||||
P99 Latency: 2.251087ms
|
|
||||||
Bottom 10% Avg Latency: 1.16922ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.02899167s
|
|
||||||
Total Events: 9415
|
|
||||||
Events/sec: 156.84
|
|
||||||
Success Rate: 94.2%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 147 MB
|
|
||||||
Avg Latency: 16.723365ms
|
|
||||||
P90 Latency: 39.058801ms
|
|
||||||
P95 Latency: 41.904891ms
|
|
||||||
P99 Latency: 47.156263ms
|
|
||||||
Bottom 10% Avg Latency: 42.800456ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.279192867s
|
|
||||||
Total Events: 890
|
|
||||||
Events/sec: 14.76
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 156 MB
|
|
||||||
Avg Latency: 448.809547ms
|
|
||||||
P90 Latency: 524.488485ms
|
|
||||||
P95 Latency: 607.28509ms
|
|
||||||
P99 Latency: 786.387053ms
|
|
||||||
Bottom 10% Avg Latency: 634.016595ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.190785048s
|
|
||||||
Total Events: 10469
|
|
||||||
Events/sec: 173.93
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 226 MB
|
|
||||||
Avg Latency: 17.73903ms
|
|
||||||
P90 Latency: 561.359µs
|
|
||||||
P95 Latency: 1.158136ms
|
|
||||||
P99 Latency: 407.947907ms
|
|
||||||
Bottom 10% Avg Latency: 174.508065ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_nostr-rs-relay_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_nostr-rs-relay_8/benchmark_report.adoc
|
|
||||||
1758366272164052ℹ️/tmp/benchmark_nostr-rs-relay_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758366274030399ℹ️/tmp/benchmark_nostr-rs-relay_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758366274036413ℹ️/tmp/benchmark_nostr-rs-relay_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: nostr-rs-relay
|
|
||||||
RELAY_URL: ws://nostr-rs-relay:8080
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T11:04:34+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_relayer-basic_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758364801895559ℹ️/tmp/benchmark_relayer-basic_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758364801896041ℹ️/tmp/benchmark_relayer-basic_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758364801896078ℹ️/tmp/benchmark_relayer-basic_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758364801896347ℹ️(*types.Uint32)(0xc0001a801c)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758364801896400ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.050770003s
|
|
||||||
Events/sec: 1104.88
|
|
||||||
Avg latency: 433.89µs
|
|
||||||
P90 latency: 567.261µs
|
|
||||||
P95 latency: 617.868µs
|
|
||||||
P99 latency: 783.593µs
|
|
||||||
Bottom 10% Avg latency: 653.813µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 183.738134ms
|
|
||||||
Burst completed: 1000 events in 155.035832ms
|
|
||||||
Burst completed: 1000 events in 160.066514ms
|
|
||||||
Burst completed: 1000 events in 183.724238ms
|
|
||||||
Burst completed: 1000 events in 178.910929ms
|
|
||||||
Burst completed: 1000 events in 168.905441ms
|
|
||||||
Burst completed: 1000 events in 172.584809ms
|
|
||||||
Burst completed: 1000 events in 177.214508ms
|
|
||||||
Burst completed: 1000 events in 169.921566ms
|
|
||||||
Burst completed: 1000 events in 162.042488ms
|
|
||||||
Burst test completed: 10000 events in 15.572250139s
|
|
||||||
Events/sec: 642.17
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 44.509677166s
|
|
||||||
Combined ops/sec: 224.67
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3253 queries in 1m0.095238426s
|
|
||||||
Queries/sec: 54.13
|
|
||||||
Avg query latency: 122.100718ms
|
|
||||||
P95 query latency: 140.360749ms
|
|
||||||
P99 query latency: 148.353154ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11408 operations (1408 queries, 10000 writes) in 1m0.117581615s
|
|
||||||
Operations/sec: 189.76
|
|
||||||
Avg latency: 16.525268ms
|
|
||||||
Avg query latency: 130.972853ms
|
|
||||||
Avg write latency: 411.048µs
|
|
||||||
P95 latency: 132.130964ms
|
|
||||||
P99 latency: 146.285305ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.265496879s
|
|
||||||
Events/sec: 1079.27
|
|
||||||
Avg latency: 529.266µs
|
|
||||||
P90 latency: 658.033µs
|
|
||||||
P95 latency: 732.024µs
|
|
||||||
P99 latency: 953.285µs
|
|
||||||
Bottom 10% Avg latency: 1.168714ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 172.300479ms
|
|
||||||
Burst completed: 1000 events in 149.247397ms
|
|
||||||
Burst completed: 1000 events in 170.000198ms
|
|
||||||
Burst completed: 1000 events in 133.786958ms
|
|
||||||
Burst completed: 1000 events in 172.157036ms
|
|
||||||
Burst completed: 1000 events in 153.284738ms
|
|
||||||
Burst completed: 1000 events in 166.711903ms
|
|
||||||
Burst completed: 1000 events in 170.635427ms
|
|
||||||
Burst completed: 1000 events in 153.381031ms
|
|
||||||
Burst completed: 1000 events in 162.125949ms
|
|
||||||
Burst test completed: 10000 events in 16.674963543s
|
|
||||||
Events/sec: 599.70
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4665 reads in 1m0.035358264s
|
|
||||||
Combined ops/sec: 160.99
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 944 queries in 1m0.383519958s
|
|
||||||
Queries/sec: 15.63
|
|
||||||
Avg query latency: 421.75292ms
|
|
||||||
P95 query latency: 491.340259ms
|
|
||||||
P99 query latency: 664.614262ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10479 operations (479 queries, 10000 writes) in 1m0.291926697s
|
|
||||||
Operations/sec: 173.80
|
|
||||||
Avg latency: 18.049265ms
|
|
||||||
Avg query latency: 385.864458ms
|
|
||||||
Avg write latency: 430.918µs
|
|
||||||
P95 latency: 3.05038ms
|
|
||||||
P99 latency: 404.540502ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.050770003s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1104.88
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 153 MB
|
|
||||||
Avg Latency: 433.89µs
|
|
||||||
P90 Latency: 567.261µs
|
|
||||||
P95 Latency: 617.868µs
|
|
||||||
P99 Latency: 783.593µs
|
|
||||||
Bottom 10% Avg Latency: 653.813µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.572250139s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 642.17
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 134 MB
|
|
||||||
Avg Latency: 186.306µs
|
|
||||||
P90 Latency: 243.995µs
|
|
||||||
P95 Latency: 279.192µs
|
|
||||||
P99 Latency: 392.859µs
|
|
||||||
Bottom 10% Avg Latency: 303.766µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 44.509677166s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 224.67
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 163 MB
|
|
||||||
Avg Latency: 8.892738ms
|
|
||||||
P90 Latency: 19.406836ms
|
|
||||||
P95 Latency: 21.247322ms
|
|
||||||
P99 Latency: 23.452072ms
|
|
||||||
Bottom 10% Avg Latency: 21.397913ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.095238426s
|
|
||||||
Total Events: 3253
|
|
||||||
Events/sec: 54.13
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 126 MB
|
|
||||||
Avg Latency: 122.100718ms
|
|
||||||
P90 Latency: 136.523661ms
|
|
||||||
P95 Latency: 140.360749ms
|
|
||||||
P99 Latency: 148.353154ms
|
|
||||||
Bottom 10% Avg Latency: 142.067372ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.117581615s
|
|
||||||
Total Events: 11408
|
|
||||||
Events/sec: 189.76
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 149 MB
|
|
||||||
Avg Latency: 16.525268ms
|
|
||||||
P90 Latency: 121.696848ms
|
|
||||||
P95 Latency: 132.130964ms
|
|
||||||
P99 Latency: 146.285305ms
|
|
||||||
Bottom 10% Avg Latency: 134.054744ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.265496879s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1079.27
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 529.266µs
|
|
||||||
P90 Latency: 658.033µs
|
|
||||||
P95 Latency: 732.024µs
|
|
||||||
P99 Latency: 953.285µs
|
|
||||||
Bottom 10% Avg Latency: 1.168714ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 16.674963543s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 599.70
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 142 MB
|
|
||||||
Avg Latency: 264.288µs
|
|
||||||
P90 Latency: 350.187µs
|
|
||||||
P95 Latency: 519.139µs
|
|
||||||
P99 Latency: 1.961326ms
|
|
||||||
Bottom 10% Avg Latency: 877.366µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.035358264s
|
|
||||||
Total Events: 9665
|
|
||||||
Events/sec: 160.99
|
|
||||||
Success Rate: 96.7%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 151 MB
|
|
||||||
Avg Latency: 16.019245ms
|
|
||||||
P90 Latency: 36.340362ms
|
|
||||||
P95 Latency: 39.113864ms
|
|
||||||
P99 Latency: 44.271098ms
|
|
||||||
Bottom 10% Avg Latency: 40.108462ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.383519958s
|
|
||||||
Total Events: 944
|
|
||||||
Events/sec: 15.63
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 280 MB
|
|
||||||
Avg Latency: 421.75292ms
|
|
||||||
P90 Latency: 460.902551ms
|
|
||||||
P95 Latency: 491.340259ms
|
|
||||||
P99 Latency: 664.614262ms
|
|
||||||
Bottom 10% Avg Latency: 538.014725ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.291926697s
|
|
||||||
Total Events: 10479
|
|
||||||
Events/sec: 173.80
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 122 MB
|
|
||||||
Avg Latency: 18.049265ms
|
|
||||||
P90 Latency: 843.867µs
|
|
||||||
P95 Latency: 3.05038ms
|
|
||||||
P99 Latency: 404.540502ms
|
|
||||||
Bottom 10% Avg Latency: 177.245211ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_relayer-basic_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_relayer-basic_8/benchmark_report.adoc
|
|
||||||
1758365287933287ℹ️/tmp/benchmark_relayer-basic_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758365289807797ℹ️/tmp/benchmark_relayer-basic_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758365289812921ℹ️/tmp/benchmark_relayer-basic_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: relayer-basic
|
|
||||||
RELAY_URL: ws://relayer-basic:7447
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T10:48:10+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
Starting Nostr Relay Benchmark
|
|
||||||
Data Directory: /tmp/benchmark_strfry_8
|
|
||||||
Events: 10000, Workers: 8, Duration: 1m0s
|
|
||||||
1758365295110579ℹ️/tmp/benchmark_strfry_8: All 0 tables opened in 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/levels.go:161 /build/pkg/database/logger.go:57
|
|
||||||
1758365295111085ℹ️/tmp/benchmark_strfry_8: Discard stats nextEmptySlot: 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/discard.go:55 /build/pkg/database/logger.go:57
|
|
||||||
1758365295111113ℹ️/tmp/benchmark_strfry_8: Set nextTxnTs to 0
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:358 /build/pkg/database/logger.go:57
|
|
||||||
1758365295111319ℹ️(*types.Uint32)(0xc000141a3c)({
|
|
||||||
value: (uint32) 1
|
|
||||||
})
|
|
||||||
/build/pkg/database/migrations.go:65
|
|
||||||
1758365295111354ℹ️migrating to version 1... /build/pkg/database/migrations.go:79
|
|
||||||
|
|
||||||
=== Starting test round 1/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.170212358s
|
|
||||||
Events/sec: 1090.49
|
|
||||||
Avg latency: 448.058µs
|
|
||||||
P90 latency: 597.558µs
|
|
||||||
P95 latency: 667.141µs
|
|
||||||
P99 latency: 920.784µs
|
|
||||||
Bottom 10% Avg latency: 729.464µs
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 172.138862ms
|
|
||||||
Burst completed: 1000 events in 168.99322ms
|
|
||||||
Burst completed: 1000 events in 162.213786ms
|
|
||||||
Burst completed: 1000 events in 161.027417ms
|
|
||||||
Burst completed: 1000 events in 183.148824ms
|
|
||||||
Burst completed: 1000 events in 178.152837ms
|
|
||||||
Burst completed: 1000 events in 158.65623ms
|
|
||||||
Burst completed: 1000 events in 186.7166ms
|
|
||||||
Burst completed: 1000 events in 177.202878ms
|
|
||||||
Burst completed: 1000 events in 182.780071ms
|
|
||||||
Burst test completed: 10000 events in 15.336760896s
|
|
||||||
Events/sec: 652.03
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 5000 reads in 44.257468151s
|
|
||||||
Combined ops/sec: 225.95
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 3002 queries in 1m0.091429487s
|
|
||||||
Queries/sec: 49.96
|
|
||||||
Avg query latency: 131.632043ms
|
|
||||||
P95 query latency: 175.810416ms
|
|
||||||
P99 query latency: 228.52716ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 11308 operations (1308 queries, 10000 writes) in 1m0.111257202s
|
|
||||||
Operations/sec: 188.12
|
|
||||||
Avg latency: 16.193707ms
|
|
||||||
Avg query latency: 137.019852ms
|
|
||||||
Avg write latency: 389.647µs
|
|
||||||
P95 latency: 136.70132ms
|
|
||||||
P99 latency: 156.996779ms
|
|
||||||
|
|
||||||
Pausing 10s before next round...
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
=== Starting test round 2/2 ===
|
|
||||||
RunPeakThroughputTest..
|
|
||||||
|
|
||||||
=== Peak Throughput Test ===
|
|
||||||
Events saved: 10000/10000 (100.0%)
|
|
||||||
Duration: 9.102738s
|
|
||||||
Events/sec: 1098.57
|
|
||||||
Avg latency: 493.093µs
|
|
||||||
P90 latency: 605.684µs
|
|
||||||
P95 latency: 659.477µs
|
|
||||||
P99 latency: 826.344µs
|
|
||||||
Bottom 10% Avg latency: 1.097884ms
|
|
||||||
RunBurstPatternTest..
|
|
||||||
|
|
||||||
=== Burst Pattern Test ===
|
|
||||||
Burst completed: 1000 events in 178.755916ms
|
|
||||||
Burst completed: 1000 events in 170.810722ms
|
|
||||||
Burst completed: 1000 events in 166.730701ms
|
|
||||||
Burst completed: 1000 events in 172.177576ms
|
|
||||||
Burst completed: 1000 events in 164.907178ms
|
|
||||||
Burst completed: 1000 events in 153.267727ms
|
|
||||||
Burst completed: 1000 events in 157.855743ms
|
|
||||||
Burst completed: 1000 events in 159.632496ms
|
|
||||||
Burst completed: 1000 events in 160.802526ms
|
|
||||||
Burst completed: 1000 events in 178.513954ms
|
|
||||||
Burst test completed: 10000 events in 15.535933443s
|
|
||||||
Events/sec: 643.67
|
|
||||||
RunMixedReadWriteTest..
|
|
||||||
|
|
||||||
=== Mixed Read/Write Test ===
|
|
||||||
Pre-populating database for read tests...
|
|
||||||
Mixed test completed: 5000 writes, 4550 reads in 1m0.032080518s
|
|
||||||
Combined ops/sec: 159.08
|
|
||||||
RunQueryTest..
|
|
||||||
|
|
||||||
=== Query Test ===
|
|
||||||
Pre-populating database with 10000 events for query tests...
|
|
||||||
Query test completed: 913 queries in 1m0.248877091s
|
|
||||||
Queries/sec: 15.15
|
|
||||||
Avg query latency: 436.472206ms
|
|
||||||
P95 query latency: 493.12732ms
|
|
||||||
P99 query latency: 623.201275ms
|
|
||||||
RunConcurrentQueryStoreTest..
|
|
||||||
|
|
||||||
=== Concurrent Query/Store Test ===
|
|
||||||
Pre-populating database with 5000 events for concurrent query/store test...
|
|
||||||
Concurrent test completed: 10470 operations (470 queries, 10000 writes) in 1m0.293280495s
|
|
||||||
Operations/sec: 173.65
|
|
||||||
Avg latency: 18.084009ms
|
|
||||||
Avg query latency: 395.171481ms
|
|
||||||
Avg write latency: 360.898µs
|
|
||||||
P95 latency: 1.338148ms
|
|
||||||
P99 latency: 413.21015ms
|
|
||||||
|
|
||||||
=== Test round completed ===
|
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
BENCHMARK REPORT
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.170212358s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1090.49
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 108 MB
|
|
||||||
Avg Latency: 448.058µs
|
|
||||||
P90 Latency: 597.558µs
|
|
||||||
P95 Latency: 667.141µs
|
|
||||||
P99 Latency: 920.784µs
|
|
||||||
Bottom 10% Avg Latency: 729.464µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.336760896s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 652.03
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 123 MB
|
|
||||||
Avg Latency: 189.06µs
|
|
||||||
P90 Latency: 248.714µs
|
|
||||||
P95 Latency: 290.433µs
|
|
||||||
P99 Latency: 416.924µs
|
|
||||||
Bottom 10% Avg Latency: 324.174µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 44.257468151s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 225.95
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 158 MB
|
|
||||||
Avg Latency: 8.745534ms
|
|
||||||
P90 Latency: 18.980294ms
|
|
||||||
P95 Latency: 20.822884ms
|
|
||||||
P99 Latency: 23.124918ms
|
|
||||||
Bottom 10% Avg Latency: 21.006886ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.091429487s
|
|
||||||
Total Events: 3002
|
|
||||||
Events/sec: 49.96
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 191 MB
|
|
||||||
Avg Latency: 131.632043ms
|
|
||||||
P90 Latency: 152.618309ms
|
|
||||||
P95 Latency: 175.810416ms
|
|
||||||
P99 Latency: 228.52716ms
|
|
||||||
Bottom 10% Avg Latency: 186.230874ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.111257202s
|
|
||||||
Total Events: 11308
|
|
||||||
Events/sec: 188.12
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 146 MB
|
|
||||||
Avg Latency: 16.193707ms
|
|
||||||
P90 Latency: 122.204256ms
|
|
||||||
P95 Latency: 136.70132ms
|
|
||||||
P99 Latency: 156.996779ms
|
|
||||||
Bottom 10% Avg Latency: 140.031139ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Peak Throughput
|
|
||||||
Duration: 9.102738s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 1098.57
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 1441 MB
|
|
||||||
Avg Latency: 493.093µs
|
|
||||||
P90 Latency: 605.684µs
|
|
||||||
P95 Latency: 659.477µs
|
|
||||||
P99 Latency: 826.344µs
|
|
||||||
Bottom 10% Avg Latency: 1.097884ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Burst Pattern
|
|
||||||
Duration: 15.535933443s
|
|
||||||
Total Events: 10000
|
|
||||||
Events/sec: 643.67
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 130 MB
|
|
||||||
Avg Latency: 186.177µs
|
|
||||||
P90 Latency: 243.915µs
|
|
||||||
P95 Latency: 276.146µs
|
|
||||||
P99 Latency: 418.787µs
|
|
||||||
Bottom 10% Avg Latency: 309.015µs
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Mixed Read/Write
|
|
||||||
Duration: 1m0.032080518s
|
|
||||||
Total Events: 9550
|
|
||||||
Events/sec: 159.08
|
|
||||||
Success Rate: 95.5%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 115 MB
|
|
||||||
Avg Latency: 16.401942ms
|
|
||||||
P90 Latency: 37.575878ms
|
|
||||||
P95 Latency: 40.323279ms
|
|
||||||
P99 Latency: 45.453669ms
|
|
||||||
Bottom 10% Avg Latency: 41.331235ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Query Performance
|
|
||||||
Duration: 1m0.248877091s
|
|
||||||
Total Events: 913
|
|
||||||
Events/sec: 15.15
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 211 MB
|
|
||||||
Avg Latency: 436.472206ms
|
|
||||||
P90 Latency: 474.430346ms
|
|
||||||
P95 Latency: 493.12732ms
|
|
||||||
P99 Latency: 623.201275ms
|
|
||||||
Bottom 10% Avg Latency: 523.084076ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Test: Concurrent Query/Store
|
|
||||||
Duration: 1m0.293280495s
|
|
||||||
Total Events: 10470
|
|
||||||
Events/sec: 173.65
|
|
||||||
Success Rate: 100.0%
|
|
||||||
Concurrent Workers: 8
|
|
||||||
Memory Used: 171 MB
|
|
||||||
Avg Latency: 18.084009ms
|
|
||||||
P90 Latency: 624.339µs
|
|
||||||
P95 Latency: 1.338148ms
|
|
||||||
P99 Latency: 413.21015ms
|
|
||||||
Bottom 10% Avg Latency: 177.8924ms
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Report saved to: /tmp/benchmark_strfry_8/benchmark_report.txt
|
|
||||||
AsciiDoc report saved to: /tmp/benchmark_strfry_8/benchmark_report.adoc
|
|
||||||
1758365779337138ℹ️/tmp/benchmark_strfry_8: Lifetime L0 stalled for: 0s
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:536 /build/pkg/database/logger.go:57
|
|
||||||
1758365780726692ℹ️/tmp/benchmark_strfry_8:
|
|
||||||
Level 0 [ ]: NumTables: 00. Size: 0 B of 0 B. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 64 MiB
|
|
||||||
Level 1 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 2 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 3 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 4 [ ]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 5 [B]: NumTables: 00. Size: 0 B of 10 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 2.0 MiB
|
|
||||||
Level 6 [ ]: NumTables: 04. Size: 87 MiB of 87 MiB. Score: 0.00->0.00 StaleData: 0 B Target FileSize: 4.0 MiB
|
|
||||||
Level Done
|
|
||||||
/go/pkg/mod/github.com/dgraph-io/badger/v4@v4.8.0/db.go:615 /build/pkg/database/logger.go:57
|
|
||||||
1758365780732292ℹ️/tmp/benchmark_strfry_8: database closed /build/pkg/database/database.go:134
|
|
||||||
|
|
||||||
RELAY_NAME: strfry
|
|
||||||
RELAY_URL: ws://strfry:8080
|
|
||||||
TEST_TIMESTAMP: 2025-09-20T10:56:20+00:00
|
|
||||||
BENCHMARK_CONFIG:
|
|
||||||
Events: 10000
|
|
||||||
Workers: 8
|
|
||||||
Duration: 60s
|
|
||||||
@@ -63,9 +63,9 @@ echo ""
|
|||||||
# Run the benchmark binary directly against the running ORLY instance
|
# Run the benchmark binary directly against the running ORLY instance
|
||||||
docker run --rm --network benchmark_benchmark-net \
|
docker run --rm --network benchmark_benchmark-net \
|
||||||
-e BENCHMARK_TARGETS=next-orly:8080 \
|
-e BENCHMARK_TARGETS=next-orly:8080 \
|
||||||
-e BENCHMARK_EVENTS=50000 \
|
-e BENCHMARK_EVENTS=10000 \
|
||||||
-e BENCHMARK_WORKERS=24 \
|
-e BENCHMARK_WORKERS=24 \
|
||||||
-e BENCHMARK_DURATION=60s \
|
-e BENCHMARK_DURATION=20s \
|
||||||
-v "$(pwd)/reports:/reports" \
|
-v "$(pwd)/reports:/reports" \
|
||||||
benchmark-benchmark-runner \
|
benchmark-benchmark-runner \
|
||||||
/app/benchmark-runner --output-dir=/reports
|
/app/benchmark-runner --output-dir=/reports
|
||||||
|
|||||||
@@ -12,19 +12,21 @@ import (
|
|||||||
"github.com/dgraph-io/badger/v4/options"
|
"github.com/dgraph-io/badger/v4/options"
|
||||||
"lol.mleku.dev"
|
"lol.mleku.dev"
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
|
"next.orly.dev/pkg/database/querycache"
|
||||||
"next.orly.dev/pkg/utils/apputil"
|
"next.orly.dev/pkg/utils/apputil"
|
||||||
"next.orly.dev/pkg/utils/units"
|
"next.orly.dev/pkg/utils/units"
|
||||||
)
|
)
|
||||||
|
|
||||||
// D implements the Database interface using Badger as the storage backend
|
// D implements the Database interface using Badger as the storage backend
|
||||||
type D struct {
|
type D struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
dataDir string
|
dataDir string
|
||||||
Logger *logger
|
Logger *logger
|
||||||
*badger.DB
|
*badger.DB
|
||||||
seq *badger.Sequence
|
seq *badger.Sequence
|
||||||
ready chan struct{} // Closed when database is ready to serve requests
|
ready chan struct{} // Closed when database is ready to serve requests
|
||||||
|
queryCache *querycache.EventCache
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure D implements Database interface at compile time
|
// Ensure D implements Database interface at compile time
|
||||||
@@ -35,14 +37,29 @@ func New(
|
|||||||
) (
|
) (
|
||||||
d *D, err error,
|
d *D, err error,
|
||||||
) {
|
) {
|
||||||
|
// Initialize query cache with configurable size (default 512MB)
|
||||||
|
queryCacheSize := int64(512 * 1024 * 1024) // 512 MB
|
||||||
|
if v := os.Getenv("ORLY_QUERY_CACHE_SIZE_MB"); v != "" {
|
||||||
|
if n, perr := strconv.Atoi(v); perr == nil && n > 0 {
|
||||||
|
queryCacheSize = int64(n * 1024 * 1024)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryCacheMaxAge := 5 * time.Minute // Default 5 minutes
|
||||||
|
if v := os.Getenv("ORLY_QUERY_CACHE_MAX_AGE"); v != "" {
|
||||||
|
if duration, perr := time.ParseDuration(v); perr == nil {
|
||||||
|
queryCacheMaxAge = duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d = &D{
|
d = &D{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
dataDir: dataDir,
|
dataDir: dataDir,
|
||||||
Logger: NewLogger(lol.GetLogLevel(logLevel), dataDir),
|
Logger: NewLogger(lol.GetLogLevel(logLevel), dataDir),
|
||||||
DB: nil,
|
DB: nil,
|
||||||
seq: nil,
|
seq: nil,
|
||||||
ready: make(chan struct{}),
|
ready: make(chan struct{}),
|
||||||
|
queryCache: querycache.NewEventCache(queryCacheSize, queryCacheMaxAge),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the data directory exists
|
// Ensure the data directory exists
|
||||||
@@ -198,6 +215,21 @@ func (d *D) Sync() (err error) {
|
|||||||
return d.DB.Sync()
|
return d.DB.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryCacheStats returns statistics about the query cache
|
||||||
|
func (d *D) QueryCacheStats() querycache.CacheStats {
|
||||||
|
if d.queryCache == nil {
|
||||||
|
return querycache.CacheStats{}
|
||||||
|
}
|
||||||
|
return d.queryCache.Stats()
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidateQueryCache clears all entries from the query cache
|
||||||
|
func (d *D) InvalidateQueryCache() {
|
||||||
|
if d.queryCache != nil {
|
||||||
|
d.queryCache.Invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Close releases resources and closes the database.
|
// Close releases resources and closes the database.
|
||||||
func (d *D) Close() (err error) {
|
func (d *D) Close() (err error) {
|
||||||
if d.seq != nil {
|
if d.seq != nil {
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ func (d *D) QueryAllVersions(c context.Context, f *filter.F) (
|
|||||||
func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDeleteEvents bool, showAllVersions bool) (
|
func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDeleteEvents bool, showAllVersions bool) (
|
||||||
evs event.S, err error,
|
evs event.S, err error,
|
||||||
) {
|
) {
|
||||||
|
// Try cache first (only for standard queries, not special cases)
|
||||||
|
if d.queryCache != nil && !showAllVersions && includeDeleteEvents {
|
||||||
|
if cachedEvents, found := d.queryCache.Get(f); found {
|
||||||
|
log.D.F("QueryEventsWithOptions: returning %d cached events", len(cachedEvents))
|
||||||
|
return cachedEvents, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if we should return multiple versions of replaceable events
|
// Determine if we should return multiple versions of replaceable events
|
||||||
// based on the limit parameter
|
// based on the limit parameter
|
||||||
wantMultipleVersions := showAllVersions || (f.Limit != nil && *f.Limit > 1)
|
wantMultipleVersions := showAllVersions || (f.Limit != nil && *f.Limit > 1)
|
||||||
@@ -583,6 +591,13 @@ func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDelete
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate cache with results (only for standard queries)
|
||||||
|
if d.queryCache != nil && !showAllVersions && includeDeleteEvents && len(evs) > 0 {
|
||||||
|
d.queryCache.Put(f, evs)
|
||||||
|
log.D.F("QueryEventsWithOptions: cached %d events", len(evs))
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
247
pkg/database/querycache/event_cache.go
Normal file
247
pkg/database/querycache/event_cache.go
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
package querycache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/list"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"lol.mleku.dev/log"
|
||||||
|
"next.orly.dev/pkg/encoders/event"
|
||||||
|
"next.orly.dev/pkg/encoders/filter"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// DefaultMaxSize is the default maximum cache size in bytes (512 MB)
|
||||||
|
DefaultMaxSize = 512 * 1024 * 1024
|
||||||
|
// DefaultMaxAge is the default maximum age for cache entries
|
||||||
|
DefaultMaxAge = 5 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
|
// EventCacheEntry represents a cached set of events for a filter
|
||||||
|
type EventCacheEntry struct {
|
||||||
|
FilterKey string
|
||||||
|
Events event.S // Slice of events
|
||||||
|
TotalSize int // Estimated size in bytes
|
||||||
|
LastAccess time.Time
|
||||||
|
CreatedAt time.Time
|
||||||
|
listElement *list.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventCache caches event.S results from database queries
|
||||||
|
type EventCache struct {
|
||||||
|
mu sync.RWMutex
|
||||||
|
|
||||||
|
entries map[string]*EventCacheEntry
|
||||||
|
lruList *list.List
|
||||||
|
|
||||||
|
currentSize int64
|
||||||
|
maxSize int64
|
||||||
|
maxAge time.Duration
|
||||||
|
|
||||||
|
hits uint64
|
||||||
|
misses uint64
|
||||||
|
evictions uint64
|
||||||
|
invalidations uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEventCache creates a new event cache
|
||||||
|
func NewEventCache(maxSize int64, maxAge time.Duration) *EventCache {
|
||||||
|
if maxSize <= 0 {
|
||||||
|
maxSize = DefaultMaxSize
|
||||||
|
}
|
||||||
|
if maxAge <= 0 {
|
||||||
|
maxAge = DefaultMaxAge
|
||||||
|
}
|
||||||
|
|
||||||
|
c := &EventCache{
|
||||||
|
entries: make(map[string]*EventCacheEntry),
|
||||||
|
lruList: list.New(),
|
||||||
|
maxSize: maxSize,
|
||||||
|
maxAge: maxAge,
|
||||||
|
}
|
||||||
|
|
||||||
|
go c.cleanupExpired()
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves cached events for a filter
|
||||||
|
func (c *EventCache) Get(f *filter.F) (events event.S, found bool) {
|
||||||
|
filterKey := string(f.Serialize())
|
||||||
|
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
entry, exists := c.entries[filterKey]
|
||||||
|
if !exists {
|
||||||
|
c.misses++
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if expired
|
||||||
|
if time.Since(entry.CreatedAt) > c.maxAge {
|
||||||
|
c.removeEntry(entry)
|
||||||
|
c.misses++
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update access time and move to front
|
||||||
|
entry.LastAccess = time.Now()
|
||||||
|
c.lruList.MoveToFront(entry.listElement)
|
||||||
|
|
||||||
|
c.hits++
|
||||||
|
log.D.F("event cache HIT: filter=%s events=%d", filterKey[:min(50, len(filterKey))], len(entry.Events))
|
||||||
|
|
||||||
|
return entry.Events, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put stores events in the cache
|
||||||
|
func (c *EventCache) Put(f *filter.F, events event.S) {
|
||||||
|
if len(events) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filterKey := string(f.Serialize())
|
||||||
|
|
||||||
|
// Estimate size: each event is roughly 500 bytes on average
|
||||||
|
estimatedSize := len(events) * 500
|
||||||
|
|
||||||
|
// Don't cache if too large
|
||||||
|
if int64(estimatedSize) > c.maxSize {
|
||||||
|
log.W.F("event cache: entry too large: %d bytes", estimatedSize)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
// Check if already exists
|
||||||
|
if existing, exists := c.entries[filterKey]; exists {
|
||||||
|
c.currentSize -= int64(existing.TotalSize)
|
||||||
|
existing.Events = events
|
||||||
|
existing.TotalSize = estimatedSize
|
||||||
|
existing.LastAccess = time.Now()
|
||||||
|
existing.CreatedAt = time.Now()
|
||||||
|
c.currentSize += int64(estimatedSize)
|
||||||
|
c.lruList.MoveToFront(existing.listElement)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evict if necessary
|
||||||
|
for c.currentSize+int64(estimatedSize) > c.maxSize && c.lruList.Len() > 0 {
|
||||||
|
oldest := c.lruList.Back()
|
||||||
|
if oldest != nil {
|
||||||
|
oldEntry := oldest.Value.(*EventCacheEntry)
|
||||||
|
c.removeEntry(oldEntry)
|
||||||
|
c.evictions++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new entry
|
||||||
|
entry := &EventCacheEntry{
|
||||||
|
FilterKey: filterKey,
|
||||||
|
Events: events,
|
||||||
|
TotalSize: estimatedSize,
|
||||||
|
LastAccess: time.Now(),
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.listElement = c.lruList.PushFront(entry)
|
||||||
|
c.entries[filterKey] = entry
|
||||||
|
c.currentSize += int64(estimatedSize)
|
||||||
|
|
||||||
|
log.D.F("event cache PUT: filter=%s events=%d size=%d total=%d/%d",
|
||||||
|
filterKey[:min(50, len(filterKey))], len(events), estimatedSize, c.currentSize, c.maxSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalidate clears all entries (called when new events are stored)
|
||||||
|
func (c *EventCache) Invalidate() {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
if len(c.entries) > 0 {
|
||||||
|
cleared := len(c.entries)
|
||||||
|
c.entries = make(map[string]*EventCacheEntry)
|
||||||
|
c.lruList = list.New()
|
||||||
|
c.currentSize = 0
|
||||||
|
c.invalidations += uint64(cleared)
|
||||||
|
log.T.F("event cache INVALIDATE: cleared %d entries", cleared)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// removeEntry removes an entry (must be called with lock held)
|
||||||
|
func (c *EventCache) removeEntry(entry *EventCacheEntry) {
|
||||||
|
delete(c.entries, entry.FilterKey)
|
||||||
|
c.lruList.Remove(entry.listElement)
|
||||||
|
c.currentSize -= int64(entry.TotalSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanupExpired removes expired entries periodically
|
||||||
|
func (c *EventCache) cleanupExpired() {
|
||||||
|
ticker := time.NewTicker(1 * time.Minute)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for range ticker.C {
|
||||||
|
c.mu.Lock()
|
||||||
|
now := time.Now()
|
||||||
|
var toRemove []*EventCacheEntry
|
||||||
|
|
||||||
|
for _, entry := range c.entries {
|
||||||
|
if now.Sub(entry.CreatedAt) > c.maxAge {
|
||||||
|
toRemove = append(toRemove, entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range toRemove {
|
||||||
|
c.removeEntry(entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(toRemove) > 0 {
|
||||||
|
log.D.F("event cache cleanup: removed %d expired entries", len(toRemove))
|
||||||
|
}
|
||||||
|
|
||||||
|
c.mu.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheStats holds cache performance metrics
|
||||||
|
type CacheStats struct {
|
||||||
|
Entries int
|
||||||
|
CurrentSize int64
|
||||||
|
MaxSize int64
|
||||||
|
Hits uint64
|
||||||
|
Misses uint64
|
||||||
|
HitRate float64
|
||||||
|
Evictions uint64
|
||||||
|
Invalidations uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stats returns cache statistics
|
||||||
|
func (c *EventCache) Stats() CacheStats {
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
|
||||||
|
total := c.hits + c.misses
|
||||||
|
hitRate := 0.0
|
||||||
|
if total > 0 {
|
||||||
|
hitRate = float64(c.hits) / float64(total)
|
||||||
|
}
|
||||||
|
|
||||||
|
return CacheStats{
|
||||||
|
Entries: len(c.entries),
|
||||||
|
CurrentSize: c.currentSize,
|
||||||
|
MaxSize: c.maxSize,
|
||||||
|
Hits: c.hits,
|
||||||
|
Misses: c.misses,
|
||||||
|
HitRate: hitRate,
|
||||||
|
Evictions: c.evictions,
|
||||||
|
Invalidations: c.invalidations,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func min(a, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dgraph-io/badger/v4"
|
"github.com/dgraph-io/badger/v4"
|
||||||
@@ -34,7 +36,9 @@ func (d *D) GetSerialsFromFilter(f *filter.F) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Pre-allocate slice with estimated capacity to reduce reallocations
|
// Pre-allocate slice with estimated capacity to reduce reallocations
|
||||||
sers = make(types.Uint40s, 0, len(idxs)*100) // Estimate 100 serials per index
|
sers = make(
|
||||||
|
types.Uint40s, 0, len(idxs)*100,
|
||||||
|
) // Estimate 100 serials per index
|
||||||
for _, idx := range idxs {
|
for _, idx := range idxs {
|
||||||
var s types.Uint40s
|
var s types.Uint40s
|
||||||
if s, err = d.GetSerialsByRange(idx); chk.E(err) {
|
if s, err = d.GetSerialsByRange(idx); chk.E(err) {
|
||||||
@@ -111,13 +115,13 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
err = errors.New("nil event")
|
err = errors.New("nil event")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reject ephemeral events (kinds 20000-29999) - they should never be stored
|
// Reject ephemeral events (kinds 20000-29999) - they should never be stored
|
||||||
if ev.Kind >= 20000 && ev.Kind <= 29999 {
|
if ev.Kind >= 20000 && ev.Kind <= 29999 {
|
||||||
err = errors.New("blocked: ephemeral events should not be stored")
|
err = errors.New("blocked: ephemeral events should not be stored")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the event already exists
|
// check if the event already exists
|
||||||
var ser *types.Uint40
|
var ser *types.Uint40
|
||||||
if ser, err = d.GetSerialById(ev.ID); err == nil && ser != nil {
|
if ser, err = d.GetSerialById(ev.ID); err == nil && ser != nil {
|
||||||
@@ -176,7 +180,10 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
if idxs, err = GetIndexesForEvent(ev, serial); chk.E(err) {
|
if idxs, err = GetIndexesForEvent(ev, serial); chk.E(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.T.F("SaveEvent: generated %d indexes for event %x (kind %d)", len(idxs), ev.ID, ev.Kind)
|
log.T.F(
|
||||||
|
"SaveEvent: generated %d indexes for event %x (kind %d)", len(idxs),
|
||||||
|
ev.ID, ev.Kind,
|
||||||
|
)
|
||||||
|
|
||||||
// Serialize event once to check size
|
// Serialize event once to check size
|
||||||
eventDataBuf := new(bytes.Buffer)
|
eventDataBuf := new(bytes.Buffer)
|
||||||
@@ -184,9 +191,15 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
eventData := eventDataBuf.Bytes()
|
eventData := eventDataBuf.Bytes()
|
||||||
|
|
||||||
// Determine storage strategy (Reiser4 optimizations)
|
// Determine storage strategy (Reiser4 optimizations)
|
||||||
// 384 bytes covers: ID(32) + Pubkey(32) + Sig(64) + basic fields + small content
|
// Get threshold from environment, default to 0 (disabled)
|
||||||
const smallEventThreshold = 384
|
// When enabled, typical values: 384 (conservative), 512 (recommended), 1024 (aggressive)
|
||||||
isSmallEvent := len(eventData) <= smallEventThreshold
|
smallEventThreshold := 1024
|
||||||
|
if v := os.Getenv("ORLY_INLINE_EVENT_THRESHOLD"); v != "" {
|
||||||
|
if n, perr := strconv.Atoi(v); perr == nil && n >= 0 {
|
||||||
|
smallEventThreshold = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isSmallEvent := smallEventThreshold > 0 && len(eventData) <= smallEventThreshold
|
||||||
isReplaceableEvent := kind.IsReplaceable(ev.Kind)
|
isReplaceableEvent := kind.IsReplaceable(ev.Kind)
|
||||||
isAddressableEvent := kind.IsParameterizedReplaceable(ev.Kind)
|
isAddressableEvent := kind.IsParameterizedReplaceable(ev.Kind)
|
||||||
|
|
||||||
@@ -224,7 +237,9 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Append size as uint16 big-endian (2 bytes for size up to 65535)
|
// Append size as uint16 big-endian (2 bytes for size up to 65535)
|
||||||
sizeBytes := []byte{byte(len(eventData) >> 8), byte(len(eventData))}
|
sizeBytes := []byte{
|
||||||
|
byte(len(eventData) >> 8), byte(len(eventData)),
|
||||||
|
}
|
||||||
keyBuf.Write(sizeBytes)
|
keyBuf.Write(sizeBytes)
|
||||||
// Append event data
|
// Append event data
|
||||||
keyBuf.Write(eventData)
|
keyBuf.Write(eventData)
|
||||||
@@ -232,7 +247,10 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
if err = txn.Set(keyBuf.Bytes(), nil); chk.E(err) {
|
if err = txn.Set(keyBuf.Bytes(), nil); chk.E(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.T.F("SaveEvent: stored small event inline (%d bytes)", len(eventData))
|
log.T.F(
|
||||||
|
"SaveEvent: stored small event inline (%d bytes)",
|
||||||
|
len(eventData),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// Large event: store separately with evt prefix
|
// Large event: store separately with evt prefix
|
||||||
keyBuf := new(bytes.Buffer)
|
keyBuf := new(bytes.Buffer)
|
||||||
@@ -242,7 +260,10 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
if err = txn.Set(keyBuf.Bytes(), eventData); chk.E(err) {
|
if err = txn.Set(keyBuf.Bytes(), eventData); chk.E(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.T.F("SaveEvent: stored large event separately (%d bytes)", len(eventData))
|
log.T.F(
|
||||||
|
"SaveEvent: stored large event separately (%d bytes)",
|
||||||
|
len(eventData),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additionally, store replaceable/addressable events with specialized keys for direct access
|
// Additionally, store replaceable/addressable events with specialized keys for direct access
|
||||||
@@ -256,11 +277,15 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
dTagHash.FromIdent(dTag.Value())
|
dTagHash.FromIdent(dTag.Value())
|
||||||
|
|
||||||
keyBuf := new(bytes.Buffer)
|
keyBuf := new(bytes.Buffer)
|
||||||
if err = indexes.AddressableEventEnc(pubHash, kindVal, dTagHash).MarshalWrite(keyBuf); chk.E(err) {
|
if err = indexes.AddressableEventEnc(
|
||||||
|
pubHash, kindVal, dTagHash,
|
||||||
|
).MarshalWrite(keyBuf); chk.E(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Append size as uint16 big-endian
|
// Append size as uint16 big-endian
|
||||||
sizeBytes := []byte{byte(len(eventData) >> 8), byte(len(eventData))}
|
sizeBytes := []byte{
|
||||||
|
byte(len(eventData) >> 8), byte(len(eventData)),
|
||||||
|
}
|
||||||
keyBuf.Write(sizeBytes)
|
keyBuf.Write(sizeBytes)
|
||||||
// Append event data
|
// Append event data
|
||||||
keyBuf.Write(eventData)
|
keyBuf.Write(eventData)
|
||||||
@@ -277,11 +302,15 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
kindVal.Set(ev.Kind)
|
kindVal.Set(ev.Kind)
|
||||||
|
|
||||||
keyBuf := new(bytes.Buffer)
|
keyBuf := new(bytes.Buffer)
|
||||||
if err = indexes.ReplaceableEventEnc(pubHash, kindVal).MarshalWrite(keyBuf); chk.E(err) {
|
if err = indexes.ReplaceableEventEnc(
|
||||||
|
pubHash, kindVal,
|
||||||
|
).MarshalWrite(keyBuf); chk.E(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Append size as uint16 big-endian
|
// Append size as uint16 big-endian
|
||||||
sizeBytes := []byte{byte(len(eventData) >> 8), byte(len(eventData))}
|
sizeBytes := []byte{
|
||||||
|
byte(len(eventData) >> 8), byte(len(eventData)),
|
||||||
|
}
|
||||||
keyBuf.Write(sizeBytes)
|
keyBuf.Write(sizeBytes)
|
||||||
// Append event data
|
// Append event data
|
||||||
keyBuf.Write(eventData)
|
keyBuf.Write(eventData)
|
||||||
@@ -297,7 +326,7 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process deletion events to actually delete the referenced events
|
// Process deletion events to actually delete the referenced events
|
||||||
if ev.Kind == kind.Deletion.K {
|
if ev.Kind == kind.Deletion.K {
|
||||||
if err = d.ProcessDelete(ev, nil); chk.E(err) {
|
if err = d.ProcessDelete(ev, nil); chk.E(err) {
|
||||||
@@ -306,5 +335,13 @@ func (d *D) SaveEvent(c context.Context, ev *event.E) (
|
|||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalidate query cache since a new event was stored
|
||||||
|
// This ensures subsequent queries will see the new event
|
||||||
|
if d.queryCache != nil {
|
||||||
|
d.queryCache.Invalidate()
|
||||||
|
log.T.F("SaveEvent: invalidated query cache")
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user