feat: parallel Loki queries with configurable thread count#27
Merged
noexecstack merged 2 commits intomainfrom Apr 1, 2026
Merged
feat: parallel Loki queries with configurable thread count#27noexecstack merged 2 commits intomainfrom
noexecstack merged 2 commits intomainfrom
Conversation
Split the Loki query time range into parallel segments fetched via ThreadPoolExecutor for significantly faster ingestion of large flow volumes. Add --loki-threads flag (default: 4) and restore default batch size to 5000 (the 120s timeout handles it). Bump to 0.11.0.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
_loki_fetch_chunk()helper that fetches a single time segment with cursor-based pagination_read_flows_loki()to split the query time range into N parallel segments usingconcurrent.futures.ThreadPoolExecutor--loki-threadsflag (default: 4) to control parallelism--loki-limitfrom 1000 back to 5000 (the 120s timeout is sufficient)Performance
For ~200k flows over a 1h window, expected improvement is roughly 10-20x (from ~6 minutes to ~20-40 seconds) due to:
Test plan
threads=1(preserving single-threaded semantics)test_parallel_merges_segmentsverifies multi-threaded fetch, timestamp ordering, and monotonic linenos