lab2 fix
Application / Lint (pull_request) Canceled after 0s
Application / Unit tests (pull_request) Canceled after 0s
Application / Docker build (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Vladislav Kunetskiy
2026-10-10 00:50:24 +03:00
parent 1e38dbdf35
commit da9fcf346a
36 changed files with 995 additions and 1038 deletions
+6 -6
View File
@@ -1,11 +1,11 @@
# API cache performance experiment
# generated: 2026-10-06T14:45:30Z
# generated: 2026-10-09T21:41:31Z
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}
{"requests": 1000, "workers": 8, "duration_seconds": 0.455918375053443, "rps": 2193.375074831716, "p50_ms": 3.3378750667907298, "p95_ms": 5.237665958702564, "p99_ms": 7.377958972938359, "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}
{"requests": 1000, "workers": 8, "duration_seconds": 0.424924207967706, "rps": 2353.360861182094, "p50_ms": 3.075250016991049, "p95_ms": 5.355541012249887, "p99_ms": 6.619499996304512, "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}
{"requests": 1000, "workers": 8, "duration_seconds": 0.5072490000165999, "rps": 1971.4183763147382, "p50_ms": 3.680104040540755, "p95_ms": 6.2174160266295075, "p99_ms": 8.554207975976169, "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}
{"requests": 1000, "workers": 8, "duration_seconds": 0.4116047500865534, "rps": 2429.51520795063, "p50_ms": 2.9188335174694657, "p95_ms": 5.480541964061558, "p99_ms": 7.245125016197562, "trial": 2, "cache_enabled": true}
{"results": [{"requests": 1000, "workers": 8, "duration_seconds": 0.455918375053443, "rps": 2193.375074831716, "p50_ms": 3.3378750667907298, "p95_ms": 5.237665958702564, "p99_ms": 7.377958972938359, "trial": 1, "cache_enabled": false}, {"requests": 1000, "workers": 8, "duration_seconds": 0.424924207967706, "rps": 2353.360861182094, "p50_ms": 3.075250016991049, "p95_ms": 5.355541012249887, "p99_ms": 6.619499996304512, "trial": 1, "cache_enabled": true}, {"requests": 1000, "workers": 8, "duration_seconds": 0.5072490000165999, "rps": 1971.4183763147382, "p50_ms": 3.680104040540755, "p95_ms": 6.2174160266295075, "p99_ms": 8.554207975976169, "trial": 2, "cache_enabled": false}, {"requests": 1000, "workers": 8, "duration_seconds": 0.4116047500865534, "rps": 2429.51520795063, "p50_ms": 2.9188335174694657, "p95_ms": 5.480541964061558, "p99_ms": 7.245125016197562, "trial": 2, "cache_enabled": true}], "users": 4, "chats": 60, "sessions_cached_in_both_modes": true}
+19 -22
View File
@@ -1,39 +1,36 @@
# Cache consistency evidence (track 1)
# generated: 2026-10-06T14:43:46Z
# generated: 2026-10-09T21:38:43Z
# redis: localhost:6379 db=1
=== RUN TestChatRepositorySuite
=== RUN TestChatRepositorySuite/TestBrokenCacheEntryIsDroppedAndRepopulated
=== RUN TestChatRepositorySuite/TestCacheUnavailableFallsBackToSource
=== RUN TestChatRepositorySuite/TestConcurrentColdReadsAreDeduplicated
chat_repository_test.go:167: distributed lock: 100 concurrent cold reads -> 1 source loads
chat_repository_test.go:226: distributed lock: 100 concurrent cold reads -> 1 source load
=== RUN TestChatRepositorySuite/TestConcurrentColdReadsWithoutProtectionStampede
chat_repository_test.go:265: stampede demonstration: 100 concurrent reads -> 100 source loads
chat_repository_test.go:427: stampede demonstration: 100 concurrent reads -> 100 source loads
=== RUN TestChatRepositorySuite/TestCreateInvalidatesMemberCaches
=== RUN TestChatRepositorySuite/TestDeeperPagesBypassCache
=== RUN TestChatRepositorySuite/TestEvictedCacheEntryReloadsFromSource
=== 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)
chat_repository_test.go:276: multi-instance distributed lock: 3 instances x 30 reads -> 1 source load
=== RUN TestChatRepositorySuite/TestSlowLoaderBeyondCacheBudgetReturnsData
=== RUN TestChatRepositorySuite/TestSourceErrorIsNotRetried
--- PASS: TestChatRepositorySuite (0.83s)
--- PASS: TestChatRepositorySuite/TestBrokenCacheEntryIsDroppedAndRepopulated (0.00s)
--- PASS: TestChatRepositorySuite/TestCacheUnavailableFallsBackToSource (0.00s)
--- PASS: TestChatRepositorySuite/TestConcurrentColdReadsAreDeduplicated (0.03s)
--- PASS: TestChatRepositorySuite/TestConcurrentColdReadsWithoutProtectionStampede (0.02s)
--- PASS: TestChatRepositorySuite/TestCreateInvalidatesMemberCaches (0.01s)
--- PASS: TestChatRepositorySuite/TestDeeperPagesBypassCache (0.00s)
--- PASS: TestChatRepositorySuite/TestEvictedCacheEntryReloadsFromSource (0.00s)
--- PASS: TestChatRepositorySuite/TestFirstPageIsCached (0.00s)
--- PASS: TestChatRepositorySuite/TestLimitIsPartOfCacheKey (0.01s)
--- PASS: TestChatRepositorySuite/TestLimitIsPartOfCacheKey (0.00s)
--- 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: TestChatRepositorySuite/TestSlowLoaderBeyondCacheBudgetReturnsData (0.70s)
--- PASS: TestChatRepositorySuite/TestSourceErrorIsNotRetried (0.00s)
PASS
ok mtusi-messenger/internal/storage/redis 0.418s
ok mtusi-messenger/internal/storage/redis 1.338s
? mtusi-messenger/internal/storage/redis/mocks [no test files]
+17 -16
View File
@@ -1,25 +1,26 @@
# Cache performance experiment
# generated: 2026-10-06T15:53:01Z
# generated: 2026-10-09T21:41:14Z
go version go1.27.1 darwin/arm64
Darwin arm64
2026/10/06 18:53:02 OK 00001_init.sql (10.14ms)
2026/10/06 18:53:02 goose: successfully migrated database to version: 1
2026/10/10 00:41:15 OK 00001_init.sql (10.03ms)
2026/10/10 00:41:15 OK 00002_user_chat_versions.sql (2.17ms)
2026/10/10 00:41:15 goose: successfully migrated database to version: 2
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:111: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.247s rps=8017 p50=6.073542ms p95=7.541167ms p99=9.156083ms
cache_performance_experiment_test.go:112: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=434ms rps=23022 p50=2.045375ms p95=3.3065ms p99=4.115042ms
cache_performance_experiment_test.go:113: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=399ms rps=25055 p50=1.948541ms p95=2.716833ms p99=3.293792ms
--- PASS: TestCachePerformanceExperiment (2.38s)
cache_performance_experiment_test.go:115: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.528s rps=6542 p50=7.490875ms p95=9.302792ms p99=10.779ms
cache_performance_experiment_test.go:116: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=851ms rps=11749 p50=4.192709ms p95=5.318916ms p99=5.905625ms
cache_performance_experiment_test.go:117: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=751ms rps=13320 p50=3.670958ms p95=4.644958ms p99=5.21475ms
--- PASS: TestCachePerformanceExperiment (3.50s)
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:111: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.275s rps=7844 p50=6.254833ms p95=7.301042ms p99=9.071333ms
cache_performance_experiment_test.go:112: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=375ms rps=26668 p50=1.822291ms p95=2.375625ms p99=3.260166ms
cache_performance_experiment_test.go:113: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=372ms rps=26890 p50=1.826083ms p95=2.368833ms p99=3.16875ms
--- PASS: TestCachePerformanceExperiment (2.26s)
cache_performance_experiment_test.go:115: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.415s rps=7066 p50=6.901958ms p95=8.697666ms p99=10.560416ms
cache_performance_experiment_test.go:116: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=846ms rps=11815 p50=4.033083ms p95=6.0305ms p99=6.963417ms
cache_performance_experiment_test.go:117: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=817ms rps=12234 p50=3.999959ms p95=5.060959ms p99=5.802042ms
--- PASS: TestCachePerformanceExperiment (3.39s)
=== RUN TestCachePerformanceExperiment
cache_performance_experiment_test.go:111: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.236s rps=8093 p50=6.084917ms p95=6.878625ms p99=7.891209ms
cache_performance_experiment_test.go:112: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=378ms rps=26432 p50=1.832208ms p95=2.499917ms p99=3.223166ms
cache_performance_experiment_test.go:113: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=404ms rps=24747 p50=1.95875ms p95=2.878375ms p99=3.453333ms
--- PASS: TestCachePerformanceExperiment (2.26s)
cache_performance_experiment_test.go:115: baseline (no cache): requests=10000 concurrency=50 sql=10000 duration=1.511s rps=6618 p50=7.302667ms p95=9.420708ms p99=12.437917ms
cache_performance_experiment_test.go:116: redis cache (cold): requests=10000 concurrency=50 sql=1 duration=827ms rps=12093 p50=3.984125ms p95=5.655167ms p99=6.8085ms
cache_performance_experiment_test.go:117: redis cache (hot): requests=10000 concurrency=50 sql=0 duration=817ms rps=12247 p50=3.946959ms p95=5.363208ms p99=6.508458ms
--- PASS: TestCachePerformanceExperiment (3.55s)
PASS
ok mtusi-messenger/internal/storage/postgres 7.277s
ok mtusi-messenger/internal/storage/postgres 10.978s
? mtusi-messenger/internal/storage/postgres/internal/sqlcgen [no test files]
? mtusi-messenger/internal/storage/postgres/migrations [no test files]
+8
View File
@@ -0,0 +1,8 @@
baseline: 6ms
after stop: 476ms
stop: n=1 max=476ms p95=476ms budget=2000ms
pause parallel: n=30 max=215ms p95=214ms budget=2000ms
create during pause: 201
after recovery: new chat visible, 5ms
lock keys without TTL: 0
PASS: redis outage handled within budget