Skip to content

feat(export-to-core): use pigz for parallel archive compression - #36

Merged
mkidambi0108 merged 7 commits into
mainfrom
feat/pigz-parallel-compression
Nov 25, 2026
Merged

mkidambi0108 merged 7 commits into
mainfrom
feat/pigz-parallel-compression

Conversation

@mkidambi0108

Copy link
Copy Markdown
Contributor

Summary

Replaces the single-threaded tar -czf - (gzip) bottleneck during Looker Core export archive packaging with multi-threaded pigz parallel compression across both mysql-data (mysqldump and mydumper modes) and fs-data, while maintaining 100% RFC 1952 .tar.gz compatibility with Looker (Google Cloud core) import jobs.

Key Changes

  • Parallel .tar.gz Packaging (looker_export.py):
    • Streams tar -cf - into pigz -c (with optional -p <PIGZ_THREADS>) before Tink Streaming AEAD (AES128_CTR_HMAC_SHA256_1MB) encryption for both encrypt_database_dump() and package_filesystem().
    • Tracks both tar and pigz child processes for signal cleanup, closes the parent's pipe read/write copy so SIGPIPE propagates cleanly, and verifies both exit codes (tar_rc == 0 and pigz_rc == 0) so upstream archive errors are never masked.
  • Automatic pigz Installation & Fallback (looker_export.py):
    • Adds USE_PIGZ (auto default, true, or false), PIGZ_THREADS (optional integer >= 1; defaults to all online vCPUs), and AUTO_INSTALL_PIGZ (true default).
    • When pigz is missing on PATH and AUTO_INSTALL_PIGZ=true, attempts non-blocking package installation via apt-get, dnf, yum, zypper, apk, or brew (probing sudo -n true in automated runs so non-root hosts without passwordless sudo never hang), falling back cleanly to single-threaded gzip when USE_PIGZ=auto.
  • Documentation (export-to-core/README.md):
    • Updates Overview, Prerequisites, Installation (apt-get / dnf commands), Usage, and the Configuration Variables Reference table (USE_PIGZ, PIGZ_THREADS, AUTO_INSTALL_PIGZ).
  • Automated Tests (export-to-core/tests/test_export_to_core.py):
    • Unit tests covering USE_PIGZ / PIGZ_THREADS / AUTO_INSTALL_PIGZ validation, automatic apt-get installation & non-passwordless-sudo fallback, and non-zero tar exit-code propagation through the tar | pigz pipeline.
    • Hermetic end-to-end integration test exercising real pigz (USE_PIGZ=true, PIGZ_THREADS=2) and USE_PIGZ=false override, verifying valid .tar.gz archives for both mysql-data and fs-data.

Verification

python3 -m unittest discover -s export-to-core/tests -p 'test_*.py' -v
# Ran 20 tests in 2.9s — OK

Add multi-threaded pigz (.tar.gz) archive compression for both mysql-data (mysqldump and mydumper modes) and fs-data, with automatic OS package installation (AUTO_INSTALL_PIGZ), configurable thread limits (USE_PIGZ, PIGZ_THREADS), clean fallback to single-threaded gzip, updated README instructions, and unit/integration tests.
@mkidambi0108
mkidambi0108 requested a review from a team as a code owner November 20, 2026 12:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces parallel archive compression using pigz for packaging database and filesystem archives, falling back to single-threaded gzip when unavailable. It also adds automatic installation of pigz via system package managers and corresponding configuration options. The review feedback suggests wrapping proc.kill() calls in try...except OSError blocks to prevent potential crashes during process cleanup, and prepending env DEBIAN_FRONTEND=noninteractive to apt-get commands to ensure they run non-interactively when executed via sudo.

Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
Comment thread export-to-core/looker_export.py Resolved
@mkidambi0108
mkidambi0108 merged commit 4006100 into main Nov 25, 2026
7 checks passed
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.

2 participants