Skip to content

feat(hoglake): time the prepare and commit phases of a flush - #170

Merged
jghoman merged 1 commit into
mainfrom
hoglake-phase-metrics
Nov 18, 2026
Merged

jghoman merged 1 commit into
mainfrom
hoglake-phase-metrics

Conversation

@jghoman

@jghoman jghoman commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Shows where a hoglake flush spends its time, so we can see what VARIANT encoding and shredding cost per record on the whales release.

Metrics

Metric Labels What it times
millpond_hoglake_prepare_seconds pipeline, broker_source, result (ok/failed) One prepare_append_tables: pre-flight reads, VARIANT encode, parquet encode, uploads. A failed attempt is timed up to the exception.
millpond_hoglake_commit_seconds pipeline, broker_source One commit_prepared the server answered 200

Together with the existing millpond_variant_encode_seconds and millpond_flush_duration_seconds, a flush's wall time per record splits into:

  • encode: millpond_variant_encode_seconds;
  • parquet + upload: prepare minus encode;
  • commit: millpond_hoglake_commit_seconds;
  • remainder: flush_duration minus prepare minus commit. That is millpond's own null-fill, cast and partition split, retry backoff, failed commit sends and already-published paths.

The full explanation is in millpond/metrics.py.

Safety

  • Guarded observes: a metrics failure is logged and changes nothing else. It can't orphan uploaded files, replace a prepare error (which the retry loop would then misclassify), or re-send a commit that landed.
  • Timer scope: the prepare timer wraps the pyhoglake call only. A test burns fake clock in millpond's own partition split to pin that.

Tests

  • TestPhaseTimings (16 tests) covers:
    • the success, failed, refused and already-published paths;
    • a replayed commit, the alignment self-heal retry and a DDL rebuild;
    • metrics failures on both observes;
    • an empty batch and an all-unplaceable flush.
  • Two review rounds (SWE and QE). A mutation pass kills every mutant, including moving the timer and dropping each guard.
  • ruff check and ruff format --check pass.
  • pytest -m "not integration and not e2e": 1727 passed, 1 skipped, 1 xfailed.

The dashboard that reads these metrics is a separate PR in PostHog/grafana-dashboards.

Add millpond_hoglake_prepare_seconds{result} (one prepare_append_tables:
pre-flight, VARIANT encode, parquet encode, uploads; ok and failed
attempts) and millpond_hoglake_commit_seconds (commit_prepared answered
200). With millpond_variant_encode_seconds and flush_duration_seconds
they split a flush's wall time per record into encode, parquet and
upload, commit and millpond's own work. Both observes are guarded so a
metrics failure cannot orphan uploads, replace the prepare error, or
re-send a landed commit.
@jghoman

jghoman commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@PostHog review

@posthog

posthog Bot commented Nov 18, 2026

Copy link
Copy Markdown

@jghoman PostHog Review is reviewing this pull request.

@jghoman
jghoman requested a review from a team November 18, 2026 17:21

@bill-ph bill-ph left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the PR description, diff, and existing discussion at 9a97557f88838bc90c71f8f748225acf3e44c043. Checked phase timing boundaries, success/failure and retry semantics, metric label binding, safeguards against metrics failures affecting uploads or commits, and added test coverage. Also checked for overengineering and scope creep. Tests, builds, and linters were not run, as requested.

No issues found.

— Robo Bill v2 (gpt-6.1-sol, high reasoning)

@posthog posthog 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.

PostHog Review · Standard · reviewed 9a97557: no findings.

@jghoman
jghoman merged commit 8d0ea5c into main Nov 18, 2026
17 checks passed
@jghoman
jghoman deleted the hoglake-phase-metrics branch November 18, 2026 17:24
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