This commit is contained in:
Vladislav Kunetskiy
2026-10-06 18:01:00 +03:00
parent 51b236a69f
commit dc743548c8
122 changed files with 10682 additions and 2139 deletions
+11
View File
@@ -0,0 +1,11 @@
# API cache performance experiment
# generated: 2026-10-06T14:45:30Z
running trial 1, cache=False, requests=1000
{"requests": 1000, "workers": 8, "duration_seconds": 0.37162104109302163, "rps": 2690.9132945184524, "p50_ms": 2.7035834500566125, "p95_ms": 4.306332906708121, "p99_ms": 10.301249916665256, "trial": 1, "cache_enabled": false}
running trial 1, cache=True, requests=1000
{"requests": 1000, "workers": 8, "duration_seconds": 0.3306667919969186, "rps": 3024.1924021488035, "p50_ms": 2.4096459965221584, "p95_ms": 3.9726250106468797, "p99_ms": 5.2115831058472395, "trial": 1, "cache_enabled": true}
running trial 2, cache=False, requests=1000
{"requests": 1000, "workers": 8, "duration_seconds": 0.36050741700455546, "rps": 2773.868033864512, "p50_ms": 2.6389374979771674, "p95_ms": 4.281750065274537, "p99_ms": 6.4238749910146, "trial": 2, "cache_enabled": false}
running trial 2, cache=True, requests=1000
{"requests": 1000, "workers": 8, "duration_seconds": 0.3070590420393273, "rps": 3256.7026633005735, "p50_ms": 2.3015625192783773, "p95_ms": 3.6923339357599616, "p99_ms": 4.840250010602176, "trial": 2, "cache_enabled": true}
{"results": [{"requests": 1000, "workers": 8, "duration_seconds": 0.37162104109302163, "rps": 2690.9132945184524, "p50_ms": 2.7035834500566125, "p95_ms": 4.306332906708121, "p99_ms": 10.301249916665256, "trial": 1, "cache_enabled": false}, {"requests": 1000, "workers": 8, "duration_seconds": 0.3306667919969186, "rps": 3024.1924021488035, "p50_ms": 2.4096459965221584, "p95_ms": 3.9726250106468797, "p99_ms": 5.2115831058472395, "trial": 1, "cache_enabled": true}, {"requests": 1000, "workers": 8, "duration_seconds": 0.36050741700455546, "rps": 2773.868033864512, "p50_ms": 2.6389374979771674, "p95_ms": 4.281750065274537, "p99_ms": 6.4238749910146, "trial": 2, "cache_enabled": false}, {"requests": 1000, "workers": 8, "duration_seconds": 0.3070590420393273, "rps": 3256.7026633005735, "p50_ms": 2.3015625192783773, "p95_ms": 3.6923339357599616, "p99_ms": 4.840250010602176, "trial": 2, "cache_enabled": true}], "users": 4, "chats": 60, "sessions_cached_in_both_modes": true}
+39
View File
@@ -0,0 +1,39 @@
# Cache consistency evidence (track 1)
# generated: 2026-10-06T14:43:46Z
# redis: localhost:6379 db=1
=== RUN TestChatRepositorySuite
=== RUN TestChatRepositorySuite/TestConcurrentColdReadsAreDeduplicated
chat_repository_test.go:167: distributed lock: 100 concurrent cold reads -> 1 source loads
=== RUN TestChatRepositorySuite/TestConcurrentColdReadsWithoutProtectionStampede
chat_repository_test.go:265: stampede demonstration: 100 concurrent reads -> 100 source loads
=== RUN TestChatRepositorySuite/TestCreateInvalidatesMemberCaches
=== RUN TestChatRepositorySuite/TestDeeperPagesBypassCache
=== RUN TestChatRepositorySuite/TestFirstPageIsCached
=== RUN TestChatRepositorySuite/TestLimitIsPartOfCacheKey
=== RUN TestChatRepositorySuite/TestMultipleInstancesShareDistributedLock
chat_repository_test.go:215: multi-instance distributed lock: 3 instances x 30 reads -> 1 source loads
--- PASS: TestChatRepositorySuite (0.14s)
--- PASS: TestChatRepositorySuite/TestConcurrentColdReadsAreDeduplicated (0.04s)
--- PASS: TestChatRepositorySuite/TestConcurrentColdReadsWithoutProtectionStampede (0.02s)
--- PASS: TestChatRepositorySuite/TestCreateInvalidatesMemberCaches (0.01s)
--- PASS: TestChatRepositorySuite/TestDeeperPagesBypassCache (0.00s)
--- PASS: TestChatRepositorySuite/TestFirstPageIsCached (0.00s)
--- PASS: TestChatRepositorySuite/TestLimitIsPartOfCacheKey (0.01s)
--- PASS: TestChatRepositorySuite/TestMultipleInstancesShareDistributedLock (0.05s)
=== RUN TestSessionRepositorySuite
=== RUN TestSessionRepositorySuite/TestCacheTTLCapAndSessionExpiry
=== RUN TestSessionRepositorySuite/TestEvictedCacheEntryReloadsFromSource
=== RUN TestSessionRepositorySuite/TestExpiredSessionIsRejected
=== RUN TestSessionRepositorySuite/TestResolveFallsBackToSourceOnMiss
=== RUN TestSessionRepositorySuite/TestResolvePopulatesCacheAndServesFromIt
=== RUN TestSessionRepositorySuite/TestRevokeEvictsCacheAndSource
--- PASS: TestSessionRepositorySuite (0.01s)
--- PASS: TestSessionRepositorySuite/TestCacheTTLCapAndSessionExpiry (0.00s)
--- PASS: TestSessionRepositorySuite/TestEvictedCacheEntryReloadsFromSource (0.00s)
--- PASS: TestSessionRepositorySuite/TestExpiredSessionIsRejected (0.00s)
--- PASS: TestSessionRepositorySuite/TestResolveFallsBackToSourceOnMiss (0.00s)
--- PASS: TestSessionRepositorySuite/TestResolvePopulatesCacheAndServesFromIt (0.00s)
--- PASS: TestSessionRepositorySuite/TestRevokeEvictsCacheAndSource (0.00s)
PASS
ok mtusi-messenger/internal/storage/redis 0.418s
+22
View File
@@ -0,0 +1,22 @@
# Cache latency experiment
# generated: 2026-10-05T19:27:40Z
go version go1.27.1 darwin/arm64
Darwin arm64
2026/10/05 22:27:42 OK 00001_init.sql (10.85ms)
2026/10/05 22:27:42 goose: successfully migrated database to version: 1
=== RUN TestCacheLatencyExperiment
cache_latency_experiment_test.go:67: baseline: requests=1000 source_loads=1000 p50=518.084µs p95=915.292µs p99=1.312875ms
cache_latency_experiment_test.go:68: redis cache: requests=1000 source_loads=1 p50=593.625µs p95=1.013958ms p99=1.388084ms
--- PASS: TestCacheLatencyExperiment (1.35s)
=== RUN TestCacheLatencyExperiment
cache_latency_experiment_test.go:67: baseline: requests=1000 source_loads=1000 p50=524.875µs p95=847.917µs p99=1.037875ms
cache_latency_experiment_test.go:68: redis cache: requests=1000 source_loads=1 p50=882.042µs p95=1.2005ms p99=1.415583ms
--- PASS: TestCacheLatencyExperiment (1.59s)
=== RUN TestCacheLatencyExperiment
cache_latency_experiment_test.go:67: baseline: requests=1000 source_loads=1000 p50=509.292µs p95=774.875µs p99=987.583µs
cache_latency_experiment_test.go:68: redis cache: requests=1000 source_loads=1 p50=475.375µs p95=927.708µs p99=1.195708ms
--- PASS: TestCacheLatencyExperiment (1.26s)
PASS
ok mtusi-messenger/internal/storage/postgres 5.016s
? mtusi-messenger/internal/storage/postgres/internal/sqlcgen [no test files]
? mtusi-messenger/internal/storage/postgres/migrations [no test files]
+25
View File
@@ -0,0 +1,25 @@
# Cache performance experiment
# generated: 2026-10-06T14:14:10Z
go version go1.27.1 darwin/arm64
Darwin arm64
2026/10/06 17:14:11 OK 00001_init.sql (10.85ms)
2026/10/06 17:14:11 goose: successfully migrated database to version: 1
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:95: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.427s rps=7009 p50=7.016292ms p95=8.510208ms p99=10.315375ms
cache_performance_experiment_test.go:96: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=971ms rps=10294 p50=4.530042ms p95=5.377208ms p99=6.060542ms
cache_performance_experiment_test.go:97: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=904ms rps=11063 p50=4.412292ms p95=5.376708ms p99=6.918458ms
--- PASS: TestCachePerformanceExperiment (3.72s)
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:95: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.339s rps=7467 p50=6.382666ms p95=8.948333ms p99=11.142875ms
cache_performance_experiment_test.go:96: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=933ms rps=10716 p50=4.333958ms p95=5.11025ms p99=5.831ms
cache_performance_experiment_test.go:97: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=893ms rps=11193 p50=4.36725ms p95=5.120666ms p99=7.455625ms
--- PASS: TestCachePerformanceExperiment (3.41s)
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:95: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.279s rps=7820 p50=6.29ms p95=7.2015ms p99=8.3035ms
cache_performance_experiment_test.go:96: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=947ms rps=10562 p50=4.364208ms p95=5.342208ms p99=6.826833ms
cache_performance_experiment_test.go:97: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=894ms rps=11186 p50=4.36925ms p95=5.278166ms p99=6.799833ms
--- PASS: TestCachePerformanceExperiment (3.36s)
PASS
ok mtusi-messenger/internal/storage/postgres 10.893s
? mtusi-messenger/internal/storage/postgres/internal/sqlcgen [no test files]
? mtusi-messenger/internal/storage/postgres/migrations [no test files]