Repository navigation
Conversation
Sparkey side inputs now call SparkeyReader.load(LoadMode.INDEX) when a reader is opened on a worker, so cold lookups need one disk read (into the log) instead of up to two. Each local file is prefetched at most once per JVM, asynchronously, and failures are logged rather than failing the job. ShardedSparkeyReader did not override load(), so it fell back to the interface's no-op default: calling load() on a sharded reader (the default for asLargeMapSideInput & co, with 64 shards) silently did nothing. It now loads every shard and combines the results. All side input constructors, including the largeHash* methods that build Sparkey side inputs internally, take a `loadMode` parameter (default SparkeyIO.DefaultLoadMode = LoadMode.INDEX); pass LoadMode.NONE to disable. The previous signatures are kept as private[sparkey] overloads for binary compatibility. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6029 +/- ##
==========================================
- Coverage 62.39% 62.32% -0.08%
==========================================
Files 326 326
Lines 11877 11925 +48
Branches 835 840 +5
==========================================
+ Hits 7411 7432 +21
- Misses 4466 4493 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Sparkey side inputs now prefetch the hash index (
.spi) into the page cache when a reader is opened on a worker, usingSparkeyReader.load(LoadMode.INDEX)from sparkey-java 3.7.0. With the index resident, a cold lookup needs one disk read (into the log) instead of up to two.This matters most for large Sparkeys that don't fit in memory on network-attached disks: Hyperdisk-balanced has roughly 450–530µs per random read in our benchmarks, and provisioning more IOPS does not reduce it, so halving reads per lookup is the main remaining lever.
Changes
ShardedSparkeyReader.loadnow works. It didn't overrideload(LoadMode, Executor), so it fell back to the interface's no-op default and returned a completed result with 0 bytes. Callingload()on a sharded reader, which is whatasLargeMapSideInputand friends produce by default (64 shards), silently did nothing. It now loads every shard and combines the results.SparkeyUri.getReader(rfu, loadMode)applies the mode after opening. Each local file is prefetched at most once per JVM, since all DoFn instances on a worker share the page cache. Loading is asynchronous, and failures are logged instead of failing the pipeline.loadModeparameter (defaultSparkeyIO.DefaultLoadMode = LoadMode.INDEX; passLoadMode.NONEto disable) on:sc.sparkeySideInput,sc.typedSparkeySideInput,sc.cachedStringSparkeySideInputasSparkeySideInput,asTypedSparkeySideInput,asCachedStringSparkeySideInput,asLargeMapSideInput,asLargeMultiMapSideInput,asLargeSetSideInputlargeHashJoin,largeHashLeftOuterJoin,largeHashFullOuterJoin,largeHashIntersectByKey,largeHashSubtractByKey(the variants that take anrhsSCollection)SCollection[SparkeyUri]helpers use the default.Compatibility
private[sparkey]overloads. These are public in bytecode, so jobs compiled against 0.16.1 keep linking, while source callers resolve to the new methods. The MiMa exclusions added tobuild.sbtcover private internals (side-input class constructors and a private helper), plus one real 2.12-only break, which needs a maintainer decision: on Scala 2.12, overloading the@experimentalsc.typedSparkeySideInputandsc.cachedStringSparkeySideInputrenames their compiled value-class extension methods ($extension→$extension0/1). Jobs compiled against 0.16.1 on 2.12 that call these two would need recompiling. 2.13 is unaffected. If that's not acceptable for a 0.16.x release, the alternative is to droploadModefrom those two methods; they'd still prefetch by default.SparkeySourceCompatTest, in a package outsidesparkey, checks that existing calls withIntliterals fornumShardsstill compile on 2.12 and 2.13. One test inside the package needed8.toShort, because it can see the private overloads.LoadMode.NONErestores the old behavior.Test plan
scio-extra/testOnly com.spotify.scio.extra.sparkey.* com.spotify.scio.extra.sparkeycompat.*on 2.13 and 2.12load(INDEX)requests exactly the sum of all shards' index sizes;getReaderwith a load mode;largeHashJoin,largeHashIntersectByKeyandasLargeMapSideInputwithLoadMode.NONE; source compatibility from outside the packagemimaReportBinaryIssueson 2.13 and 2.12,scalafmtCheckAllSparkeyTest"support concurrent sharded writes from JobTest" is flaky on 2.12 on unmodifiedmaintoo (NPE inRunEnforcementJobTest, 2 of 3 runs on8087d1c80). I also saw a single 5-minute timeout in it on this branch, which didn't recur in later runs.🤖 Generated with Claude Code