perf(interaction): fix write straggler + cache spill; integer interactionId#147
Open
d0choa wants to merge 8 commits into
Open
perf(interaction): fix write straggler + cache spill; integer interactionId#147d0choa wants to merge 8 commits into
d0choa wants to merge 8 commits into
Conversation
…vidence by interactionId
…ge tradeoff); keep STRING read repartition
…no speed gain, adds spill)
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
Builds on #145. Addresses the compute bottlenecks and storage bloat found by benchmarking the interaction step on the real
ptsDataproc topology (1 master + 2× n1-standard-8), and aligns theinteractionIdkey with the aggregation. No change to row-level results — interaction14,617,906rows, evidence27,407,354rows, full FK integrity, all runs.Changes
coalesce(2/6), which doesn't rebalance, so STRING's 13.2 M rows landed in one partition → a single ~900 s write task. Switched torepartition(...).string-interactions.txt.gzis gzip (non-splittable → 1 partition), so its transform+explode ran in one task that spilled ~12 GB. Now repartitioned at read, before the explode.interactionIdis now an 8-byte integer (xxhash64) instead of a 64-char SHA-256 — content-derived (no join), and it cut total output storage ~3× (see ladder). Zero collisions on all 14.6 M unique interactions (distinct == count)._INTERACTION_KEY_COLS(now incl.speciesA/speciesB) drives both the aggregationgroupByand the id hash, so they can't drift (closes a latent duplicate-id risk).unpersist(try/finally).Performance (vs
main, dev topology)Storage (interaction + evidence)
The residual 1.84× is the inherent cost of carrying an id in both tables; removing it entirely would mean not normalising the evidence schema (out of scope here).
Tried and reverted (kept in history for context)
repartitionByRangefor compression — won −36% evidence size but its global sort added ~+500 s. Compute-for-storage; reverted.partition_count.interactions_evidence6→16 — no speed gain and reintroduced spill, because AQEcoalescePartitionsmerges the extra partitions back towardadvisoryPartitionSizeInBytes. Reverted; the real lever isadvisoryPartitionSizeInBytes, not the repartition count.Test plan
pytest test/test_interaction.py— 13/13 (added:interactionIdisLongType; two rows differing only by species get different ids)interactionIdunique, 0 collisions🤖 Generated with Claude Code