Skip to content

Indexers Speed-ups: Implement LRU Caching and Incremental Updates#67

Open
will-bitlight wants to merge 13 commits into
BP-WG:masterfrom
will-bitlight:feature/indexer-cache-and-incremental-updates
Open

Indexers Speed-ups: Implement LRU Caching and Incremental Updates#67
will-bitlight wants to merge 13 commits into
BP-WG:masterfrom
will-bitlight:feature/indexer-cache-and-incremental-updates

Conversation

@will-bitlight

Copy link
Copy Markdown
Contributor

This PR implements the IndexerCache functionality with LRU cache management for both Esplora and Electrum indexers. It also introduces incremental update mechanisms to optimize performance and reduce network requests.

Key Changes:

  1. IndexerCache Implementation:

    • Added LRU-based caching to Indexer structures for efficient memory management.
    • Cache primarily stores transaction data, and address history.
  2. Optimization of update/create method:

    • WalletCache now primarily uses cached data, falling back to API requests for cache misses.
  3. Incremental Update Implementation:

    • Electrum Indexer:
      • Utilizes blockchain.scripthash.get_history for incremental updates.
      • Caches the last history response for each address to determine changes.
    • Esplora Indexer:
      • Uses /address/:address endpoint to fetch aggregated transaction information.
      • Compares local cached aggregates with server data to determine necessary updates.
  4. Code Refactoring:

    • Significant reduction of duplicate code in indexer implementations.
    • Encapsulated common functionality for better maintainability.
  5. Performance Improvements:

    • Reduced redundant network requests.
    • Faster data access through caching.
    • Incremental update strategy, processing only new transactions.
  6. API Compatibility:

    • Maintained existing function signatures for consistency.

Testing:

  • Local lib-testing and bin-testing shows expected behavior and performance improvements.

I look forward to your valuable suggestions, I will adjust at any time :)

@codecov

codecov Bot commented Sep 4, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 599 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.0%. Comparing base (ed03c02) to head (bcfc6c7).
⚠️ Report is 101 commits behind head on master.

Files with missing lines Patch % Lines
src/indexers/electrum.rs 0.0% 286 Missing ⚠️
src/indexers/esplora.rs 0.0% 265 Missing ⚠️
src/cli/args.rs 0.0% 15 Missing ⚠️
src/indexers/cache.rs 0.0% 13 Missing ⚠️
src/data.rs 0.0% 10 Missing ⚠️
src/wallet.rs 0.0% 7 Missing ⚠️
src/indexers/mempool.rs 0.0% 2 Missing ⚠️
src/cli/opts.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master    #67    +/-   ##
======================================
  Coverage     0.0%   0.0%            
======================================
  Files          23     24     +1     
  Lines        2071   2426   +355     
======================================
- Misses       2071   2426   +355     
Flag Coverage Δ
rust 0.0% <0.0%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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