Skip to content

Made significant optimisation changes across all features#3

Merged
Attakay78 merged 1 commit intomainfrom
optimise_codebase
Mar 11, 2026
Merged

Made significant optimisation changes across all features#3
Attakay78 merged 1 commit intomainfrom
optimise_codebase

Conversation

@Attakay78
Copy link
Owner

perf: eliminate O(N) hot-path bottlenecks for large route counts

Fixes 8 scaling bottlenecks that degrade linearly with route count. No public API changes.

Changes

File Change Before → After
engine.py + models.py Cache GlobalMaintenanceConfig in-process; use frozenset for exempt-path checks 1 backend read + O(M) list scan per request → cached; O(1) lookup
middleware.py Pre-build static/param route lookup cache at startup O(N) route walk per request → O(1) dict lookup for static paths
file.py Write-through in-memory cache; immediate flush for state, debounced (50ms) for audit Full file read+write per operation → zero reads after warm-up
redis.py Replace KEYS scan with SMEMBERS on a dedicated route-index set; per-path audit lists Blocking KEYS scan → safe SMEMBERS; fetch-1000-filter-in-Python → fetch exactly limit
memory.py deque + per-path audit index O(N) audit scan per filtered query → O(k)
openapi.py Cache filtered schema keyed to engine._schema_version O(N×verbs) rebuild per /docs request → rebuilt only on state change
engine.py + router.py register_batch(): one list_states() read for all routes at startup N get_state() reads at startup → 1 list_states() read

@Attakay78 Attakay78 merged commit 9112d96 into main Mar 11, 2026
11 checks passed
@Attakay78 Attakay78 deleted the optimise_codebase branch March 11, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant