Skip to content

Speed up ingestion (~3.3x): parallel workers, native inserts, big blocks, Rust hand_id, dedup skip/projection - #6

Merged
grenkoff merged 1 commit into
mainfrom
feature/ingest-perf
Jun 14, 2026
Merged

grenkoff merged 1 commit into
mainfrom
feature/ingest-perf

Conversation

@grenkoff

Copy link
Copy Markdown
Owner

Итог

Импорт 21 394 файлов (181 408 раздач + 10 697 турниров): ~80с → ~24с (~3.3×) на 4 воркерах локально.

6 улучшений

  1. Горизонтальное масштабирование воркеров — docker-compose worker.deploy.replicas: 3 (+ --scale); очередь Redis атомарна (BLPOP).
  2. Skip dedup на пустой базе — user_has_rows: на первом импорте не гоняем membership-запросы.
  3. Rust считает hand_id (uuid v5) + Python строит column-ordered tuples без Pydantic (build_chunk_rows/build_tournament_rows). Кросс-проверка Rust↔Python в тесте.
  4. Нативные вставки (asynch, TCP) вместо HTTP; reads остаются на clickhouse-connect. Нативный порт CH проброшен 9009:9000 (на хосте 9000 занят MinIO).
  5. Проекция дедупа p_user_hand (user_id, hand_id) (CH-миграция 0003, режим deduplicate_merge_projection_mode='rebuild' для ReplacingMergeTree) — membership становится index-seek при больших историях.
  6. Параллельное чтение файлов в браузере (конкуренция 16) вместо последовательного.

Плюс: размер блока батчера 1000 → 50000 (главный рычаг — меньше нативных round-trip'ов).

Проверки

  • cargo 11/11, ruff + mypy --strict чисто, pytest 21/21 (вкл. дедуп и Rust↔Python hand_id), frontend lint/typecheck/build.
  • Нативная вставка проверена на живом CH (Enum8/UUID/DateTime декодируются верно).
  • Throughput на 21k файлах: 24.3с end-to-end, дедуп/идемпотентность сохранены.

…t hand_id, dedup skip/projection, parallel reads
@grenkoff
grenkoff merged commit bf3ce51 into main Jun 14, 2026
3 checks passed
@grenkoff
grenkoff deleted the feature/ingest-perf branch June 14, 2026 12:28
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