Repository navigation
allowing variant walkers to configure their caching behavior - #3480
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3480 +/- ##
==============================================
+ Coverage 87.048% 87.05% +0.002%
- Complexity 31445 31447 +2
==============================================
Files 1921 1921
Lines 144977 144978 +1
Branches 16062 16062
==============================================
+ Hits 126199 126203 +4
+ Misses 12935 12932 -3
Partials 5843 5843
|
| * Subclasses can set this value by overriding this method. | ||
| * @return the number of bases ahead of a query to prefetch | ||
| */ | ||
| protected int getVariantCacheLookAheadBases(){ |
There was a problem hiding this comment.
Maybe it is a good idea to add a TODOsaying that this could be included in the config file...
droazen
left a comment
There was a problem hiding this comment.
Review complete, back to @lbergelson
| */ | ||
| protected abstract Spliterator<VariantContext> getSpliteratorForDrivingVariants(); | ||
|
|
||
| /** |
There was a problem hiding this comment.
It's not how many records -- it's how many additional bases should be queried and cached beyond the current variant upon a cache miss.
| * (specifically, the number of additional bases worth of overlapping records to cache when querying feature sources). | ||
| */ | ||
| public static final int FEATURE_CACHE_LOOKAHEAD = 100_000; | ||
| public static final int DEFAULT_FEATURE_CACHE_LOOKAHEAD = 100_000; |
There was a problem hiding this comment.
Rename this constant to make it clear it only applies to the driving input
| //Note: we override this method because we don't want to set feature manager to null if there are no FeatureInputs. | ||
| //This is because we have at least 1 source of features (namely the driving dataset). | ||
| features = new FeatureManager(this, FEATURE_CACHE_LOOKAHEAD, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, | ||
| features = new FeatureManager(this, FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, |
There was a problem hiding this comment.
Add an explicit comment pointing out that you're using a different lookahead value for side inputs.
There was a problem hiding this comment.
Also, you need to do some profiling on VariantWalkers with significant side inputs to prove that this doesn't harm performance.
| * When performing a query on the primary variant input how many overlapping records should be cached when querying. | ||
| * Subclasses can set this value by overriding this method. | ||
| * @return the number of bases ahead of a query to prefetch | ||
| */ |
There was a problem hiding this comment.
Name of this method should make it clear that it applies only to the driving input (eg., getDrivingVariantsCacheLookaheadBases())
|
|
||
| @Override | ||
| protected int getVariantCacheLookAheadBases() { | ||
| return 1000; |
There was a problem hiding this comment.
Do heavy-duty profiling to determine the effect on both the memory use and runtime of GenotypeGVCFs.
(and bear in mind that for the 20k gnomAD run, it was the native heap memory use by GenomicsDB that was a problem (10+ GB in some cases), whereas the Java heap usage stayed within a fixed and relatively low -Xmx value (4-5 GB))
|
@lbergelson Perhaps one way we could get this merged is to merge only the change that allows walkers to override the caching behavior, but keep |
|
Re-assigning to @cmnbroad |
f1c70e5 to
8fd5b2b
Compare
|
I rebased this, and responded to code review comments:
I think changing the default lookahead for VariantWalker side inputs to the new, smaller value will hurt performance for tools like VQSR. I did some crude timing tests using the FeatureDataSource default (1000 bases) proposed in this branch, and the current default (100,000 bases). The following are total times as reported by Gradle for serial runs of the VQSR integration tests: With 1000 base lookahead: With 100,000 base lookahead: Back to 1000 base lookahead again: It seems pretty consistently slower with the smaller lookahead. |
|
The more I think about it, the more I think we should consider increasing |
8fd5b2b to
7f699ac
Compare
|
I did a final rebase on this branch to account for the |
7f699ac to
efecb4c
Compare
efecb4c to
7982ac7
Compare
Adding a new method
getVariantCacheLookAheadBasestoVariantWalkerBasewhich allows subclasses to set how far to look ahead when caching variants. This may help reduce memory use in GenotypeGVCFs.This also changes the side inputs to use FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES which is
1000, this is the value used by the other tools. I'm not sure if that's the right thing to do, but it makes variant walkers more consistent with other tools. Alternatively we could add a separate configuration method that lets tools change the side input value. We could also expose an optional parameter in the feature input that lets you set that on a per input basis if we need it.This doesn't seem to have any negative effect on performance for genotypegvcfs, but it's hard to tell from short runs. It's also hard to tell if it's improving memory usage. It doesn't seem to make an appreciable difference at random places in the genome, but I'm hoping it will make a difference in very bad locations that have a lot of variation. Ideally our caches would be based on size rather than number of variants, but that's a more complicated change.
fixes #3471