Skip to content

allowing variant walkers to configure their caching behavior - #3480

Merged
droazen merged 4 commits into
masterfrom
lb_allow_customizing_caching_strategy
Jan 14, 2019
Merged

droazen merged 4 commits into
masterfrom
lb_allow_customizing_caching_strategy

Conversation

@lbergelson

@lbergelson lbergelson commented Aug 22, 2017 •

Copy link
Copy Markdown
Contributor

Adding a new method getVariantCacheLookAheadBases to VariantWalkerBase which 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

@lbergelson
lbergelson requested a review from droazen August 22, 2017 21:12
@codecov-io

codecov-io commented Aug 22, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #3480 into master will increase coverage by 0.002%.
The diff coverage is 100%.

@@              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
Impacted Files Coverage Δ Complexity Δ
...ools/funcotator/FuncotatorArgumentDefinitions.java 86.364% <ø> (ø) 1 <0> (ø) ⬇️
...nstitute/hellbender/engine/MultiVariantWalker.java 100% <100%> (ø) 16 <0> (ø) ⬇️
...institute/hellbender/engine/VariantWalkerBase.java 100% <100%> (ø) 14 <2> (+1) ⬆️
...ces/gencode/GencodeFuncotationFactoryUnitTest.java 94.033% <100%> (ø) 67 <0> (ø) ⬇️
...nstitute/hellbender/engine/VariantLocusWalker.java 89.091% <100%> (ø) 17 <0> (ø) ⬇️
...roadinstitute/hellbender/engine/VariantWalker.java 93.333% <100%> (ø) 12 <0> (ø) ⬇️
...ithwaterman/SmithWatermanIntelAlignerUnitTest.java 60% <0%> (ø) 2% <0%> (ø) ⬇️
...utils/smithwaterman/SmithWatermanIntelAligner.java 80% <0%> (+30%) 3% <0%> (+2%) ⬆️

* Subclasses can set this value by overriding this method.
* @return the number of bases ahead of a query to prefetch
*/
protected int getVariantCacheLookAheadBases(){

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.

Maybe it is a good idea to add a TODOsaying that this could be included in the config file...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I added a new issue #3489

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

Review complete, back to @lbergelson

*/
protected abstract Spliterator<VariantContext> getSpliteratorForDrivingVariants();

/**

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.

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;

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.

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,

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.

Add an explicit comment pointing out that you're using a different lookahead value for side inputs.

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.

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
*/

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.

Name of this method should make it clear that it applies only to the driving input (eg., getDrivingVariantsCacheLookaheadBases())


@Override
protected int getVariantCacheLookAheadBases() {
return 1000;

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.

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))

@droazen droazen assigned lbergelson and unassigned droazen Aug 23, 2017
@droazen

droazen commented Sep 27, 2017

Copy link
Copy Markdown
Contributor

@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 GenotypeGVCFs set to the default for now. Then, you could open a separate ticket to profile different default values for that tool and select a new default.

@droazen

droazen commented Aug 27, 2018

Copy link
Copy Markdown
Contributor

Re-assigning to @cmnbroad

@cmnbroad
cmnbroad force-pushed the lb_allow_customizing_caching_strategy branch from f1c70e5 to 8fd5b2b Compare August 30, 2018 15:18
@cmnbroad

Copy link
Copy Markdown
Contributor

I rebased this, and responded to code review comments:

  • updated comments
  • reverted GenotypeGVCFs change
  • reverted changing the default lookahead for VariantWalker side inputs

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:
1m40s
1m29s
1m29s
1m25s

With 100,000 base lookahead:
1m29s
1m17s
1m16s
1m18s

Back to 1000 base lookahead again:
1m36s
1m26s
1m26s
1m29s

It seems pretty consistently slower with the smaller lookahead.

@cmnbroad

Copy link
Copy Markdown
Contributor

The more I think about it, the more I think we should consider increasing FeatureDataSource .DEFAULT_QUERY_LOOKAHEAD_BASES to something larger than 1000.

@droazen
droazen force-pushed the lb_allow_customizing_caching_strategy branch from 8fd5b2b to 7f699ac Compare January 11, 2019 20:20
@droazen

droazen commented Jan 11, 2019

Copy link
Copy Markdown
Contributor

I did a final rebase on this branch to account for the VariantLocusWalker and to make a few minor tweaks. Will merge once tests pass.

@droazen droazen assigned droazen and unassigned cmnbroad Jan 11, 2019
@droazen
droazen force-pushed the lb_allow_customizing_caching_strategy branch from 7f699ac to efecb4c Compare January 11, 2019 20:30
@droazen
droazen force-pushed the lb_allow_customizing_caching_strategy branch from efecb4c to 7982ac7 Compare January 11, 2019 23:24
@droazen
droazen merged commit d7d62d4 into master Jan 14, 2019
@droazen
droazen deleted the lb_allow_customizing_caching_strategy branch January 14, 2019 18:48
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.

add mechanism for VariantWalkers to override FEATURE_CACHE_LOOKAHEAD

5 participants