Skip to content

Cache optimisation - #879

Closed
Peter-J-Freeman wants to merge 3 commits into
regex_removalfrom
cache_optimisation
Closed

Cache optimisation#879
Peter-J-Freeman wants to merge 3 commits into
regex_removalfrom
cache_optimisation

Conversation

@Peter-J-Freeman

Copy link
Copy Markdown
Collaborator

No description provided.

Implement in-process LRU cache decorators for the SeqFetcher and HGVS
data provider (HDP) to reduce repeated lookups during validation.

The SeqFetcher cache stores repeated fetch_seq() requests. The HDP cache
stores results from get_tx_identity_info(), get_tx_for_gene(),
get_pro_ac_for_tx_ac(), get_tx_exons(), get_gene_info() and
get_tx_mapping_options(). get_tx_for_region() was intentionally excluded
because these genomic coordinate queries are unlikely to repeat during
validation.

Both wrappers use the decorator pattern and transparently delegate all
uncached methods to the underlying implementations.

Benchmarking shows the SeqFetcher cache primarily improves runtime
stability, while the addition of the HDP cache provides a substantial
reduction in overall validation time.

Refs #876
Configure the benchmark branch with the current optimal cache
configuration identified during performance testing.

Changes:
- Increase the HGVS internal LRU cache size to 1000 entries.
- Leave the SeqFetcher cache enabled.
- Disable the Local HDP cache wrapper.
- Retain the Local HDP cache implementation in the codebase for
  future benchmarking and evaluation.

Benchmarking indicates that an HGVS LRU cache size of 1000 provides
the best balance between execution speed and expected memory usage for
the current VariantValidator workload. Increasing the cache beyond
1000 yielded only marginal additional performance improvements.
- Completed benchmarking and optimisation of the VariantValidator
  caching framework across the HGVS, SeqFetcher and DBGet layers.

- Selected the final production cache configuration following repeated
  benchmarking of the complete test suite:
  - Local HGVS HDP cache: disabled
  - SeqFetcher cache: enabled (32768 entries)
  - Global HGVS cache: 1000 entries
  - DBGet cache: enabled (15000 entries)

- Benchmarking demonstrated an expected reduction in full test suite
  runtime from approximately 26.6 minutes with all caches disabled to
  approximately 4.2 minutes using the recommended configuration,
  representing an estimated 84% reduction in execution time
  (~6.3× faster).

- Added configurable cache settings and environment variable overrides
  for all cache types.

- Added comprehensive cache documentation to settings.py describing:
  - available cache types
  - default settings
  - environment variable overrides
  - recommended production configuration
  - memory and performance considerations

- Added caching to the principal high-frequency DBGet lookup methods.

- Left the following DBGet methods intentionally uncached:
  - get_refseq_id_from_lrg_id()
  - get_refseq_transcript_id_from_lrg_transcript_id()
  - get_uta_symbol()
  - get_hgnc_symbol()
  - get_lrg_data_from_lrg_id()
  These methods are infrequently used, primarily support LRG or
  symbol-conversion workflows, or return complete database rows where
  benchmarking showed little practical benefit from caching.

- Added and updated unit tests covering cache behaviour, cache
  configuration, environment variable overrides and DBGet caching.

- Removed obsolete cache helper code and updated tests to reflect the
  final implementation.

- Cache implementation locations:
  - DBGet lookup cache:
    VariantValidator/modules/DBGet.py
  - SeqFetcher cache:
    VariantValidator/modules/vvMixinInit.py
  - HGVS HDP cache:
    VariantValidator/modules/vvMixinInit.py
  - Cache configuration and documentation:
    VariantValidator/settings.py
@Peter-J-Freeman

Peter-J-Freeman commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

This pull request replaces #877 and is the final version based on testing during optimisation

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.86%. Comparing base (650b73a) to head (5d60450).
⚠️ Report is 3 commits behind head on regex_removal.

Files with missing lines Patch % Lines
VariantValidator/modules/vvMixinInit.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           regex_removal     #879      +/-   ##
=================================================
+ Coverage          84.84%   84.86%   +0.02%     
=================================================
  Files                 48       48              
  Lines              14554    14584      +30     
=================================================
+ Hits               12348    12377      +29     
- Misses              2206     2207       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant