perf: cache /bounty, /logs/histogram, /deckies; bump /config TTL to 5s
Round-2 follow-up: profile at 500c/u showed _execute still dominating the uncached read endpoints (/bounty 76%, /logs/histogram 73%, /deckies 56%). Same router-level TTL pattern as /stats — 5s window, asyncio.Lock to collapse concurrent calls into one DB hit. - /bounty: cache default unfiltered page (limit=50, offset=0, bounty_type=None, search=None). Filtered requests bypass. - /logs/histogram: cache default (interval_minutes=15, no filters). Filtered / non-default interval requests bypass. - /deckies: cache full response (endpoint takes no params). - /config: bump _STATE_TTL from 1.0 to 5.0 — admin writes are rare, 1s was too short for bursts to coalesce at high concurrency.
This commit is contained in:
@@ -59,11 +59,17 @@ async def setup_db(monkeypatch) -> AsyncGenerator[None, None]:
|
||||
from decnet.web.router.stats import api_get_stats as _s
|
||||
from decnet.web.router.logs import api_get_logs as _l
|
||||
from decnet.web.router.attackers import api_get_attackers as _a
|
||||
from decnet.web.router.bounty import api_get_bounties as _b
|
||||
from decnet.web.router.logs import api_get_histogram as _lh
|
||||
from decnet.web.router.fleet import api_get_deckies as _d
|
||||
_h._reset_db_cache()
|
||||
_c._reset_state_cache()
|
||||
_s._reset_stats_cache()
|
||||
_l._reset_total_cache()
|
||||
_a._reset_total_cache()
|
||||
_b._reset_bounty_cache()
|
||||
_lh._reset_histogram_cache()
|
||||
_d._reset_deckies_cache()
|
||||
|
||||
# Create schema
|
||||
async with engine.begin() as conn:
|
||||
|
||||
Reference in New Issue
Block a user