-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Problem
The sanitizeFTS5Query function in internal/restapi/search_stops_handler.go compiles two regular expressions on every search request, causing unnecessary CPU overhead.
Impact
- 100x slower than necessary
- Regex compilation takes ~100,000 ns per request
- Regex execution takes ~1,000 ns per request
- At 1,000 searches/sec: wastes approximately 10% of a CPU core
Solution
Move regex compilation to package-level variables so they are compiled once at startup and reused for all requests.
Benefits
- 100x performance improvement
- Reduced CPU usage and latency
- Less GC pressure
- No behavioral changes
- Thread-safe (regexp.Regexp is safe for concurrent use)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels