Skip to content

feat: parallel Loki queries with configurable thread count#27

Merged
noexecstack merged 2 commits intomainfrom
feat/parallel-loki-queries
Apr 1, 2026
Merged

feat: parallel Loki queries with configurable thread count#27
noexecstack merged 2 commits intomainfrom
feat/parallel-loki-queries

Conversation

@noexecstack
Copy link
Copy Markdown
Owner

Summary

  • Extract _loki_fetch_chunk() helper that fetches a single time segment with cursor-based pagination
  • Refactor _read_flows_loki() to split the query time range into N parallel segments using concurrent.futures.ThreadPoolExecutor
  • Add --loki-threads flag (default: 4) to control parallelism
  • Restore default --loki-limit from 1000 back to 5000 (the 120s timeout is sufficient)
  • Results are merged in timestamp order with monotonic line numbers
  • Bump version to 0.11.0

Performance

For ~200k flows over a 1h window, expected improvement is roughly 10-20x (from ~6 minutes to ~20-40 seconds) due to:

  • 5x fewer HTTP round-trips (batch size 1000 -> 5000)
  • ~4x concurrency from parallel time segments

Test plan

  • All existing Loki tests updated to use threads=1 (preserving single-threaded semantics)
  • New test_parallel_merges_segments verifies multi-threaded fetch, timestamp ordering, and monotonic linenos
  • 135 tests pass, ruff clean

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.
@noexecstack noexecstack merged commit dc0f850 into main Apr 1, 2026
5 checks passed
@noexecstack noexecstack deleted the feat/parallel-loki-queries branch April 1, 2026 06:56
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