Repository navigation
[pull] main from miniflux:main - #315
Merged
Merged
Conversation
The old query ran two correlated subqueries per category row: one to count feeds and one to count unread entries. For N categories this meant 2xN subquery executions. This commit replaces them with two pre-aggregated subqueries joined once to categories. The ch A30F ange was validated against my live database with 5 categories, ~500 feeds and 12k unreads: | | Old (correlated) | New (pre-aggregated) | |---------------------|---------------------|------------------------| | Execution time | 3.216 ms | 3.123 ms | | Planning time | 0.732 ms | 0.778 ms | | Buffer hits | 3,141 | 540 | | Index searches | 1,237 | 1 | | Seq scans on feeds | 10 (2 per category) | 2 (once each subquery) | | Subquery executions | 10 (2x5 categories) | 2 (fixed) |
Filter rules are evaluated once per entry on every feed refresh. The previous code called regexp.Compile / regexp.MatchString per call, recompiling the same patterns N times per refresh: once per entry per filter rule, plus once per entry for feed.BlocklistRules and feed.KeeplistRules. This commit routes all regex compilations through a small cachedRegex() helper that memoizes results in a process-wide map (RWMutex protected, since we need len() and atomic reset that sync.Map doesn't expose). A nil cached value means the pattern previously failed to compile. To prevent unbounded memory growth from an authenticated user churning distinct patterns, the cache is completely reset once it reaches maxCachedRegexes entries. Benchmarked on a 50-entry refresh with 6 distinct regex rules: before: ~408 µs/op 11,580 B/op 131 allocs/op after: ~271 µs/op ~0 B/op 0 allocs/op Making it roughly 33% faster with zero allocations per feed-refresh batch, scaling linearly with entry count, yay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )