Skip to content

Implements memory-based dynamic cache flushing#7

Closed
macols77 wants to merge 3 commits into
masterfrom
feature/memory-based-flush
Closed

Implements memory-based dynamic cache flushing#7
macols77 wants to merge 3 commits into
masterfrom
feature/memory-based-flush

Conversation

@macols77

Copy link
Copy Markdown
Contributor

Replaces the fixed block commit interval with a dynamic memory-based flushing mechanism.

The indexer now monitors memory usage and flushes the cache when it reaches a certain ratio of the total available memory. This helps prevent out-of-memory errors and improves stability.

A new MemoryLimiter struct is introduced to manage memory snapshots and determine when to flush.
The flush ratio is configurable via the memory_flush_ratio option.

Removes the old commit_interval setting as it is no longer used.

Adds transaction size and weight information to the AddressTxOut data structure and populates it during index lookups.
This allows clients to have direct access to the size and weight of a transaction associated with an address output,
improving the granularity of data available to clients.
Replaces the fixed block commit interval with a dynamic memory-based flushing mechanism.

The indexer now monitors memory usage and flushes the cache when it reaches a certain ratio of the total available memory. This helps prevent out-of-memory errors and improves stability.

A new `MemoryLimiter` struct is introduced to manage memory snapshots and determine when to flush.
The flush ratio is configurable via the `memory_flush_ratio` option.

Removes the old `commit_interval` setting as it is no longer used.
Introduces a memory limiter to dynamically flush the cache when memory usage exceeds a high watermark.

Adds configurable options for memory management:
- `memory_flush_ratio`:  The memory usage ratio at which the cache is flushed.
- `memory_resume_ratio`: The memory usage ratio at which processing resumes after a flush.
- `memory_refresh_ms`: The minimum interval between memory usage checks.

Synchronously flushes the cache and waits for persistence to complete when the high watermark is reached, ensuring memory pressure is relieved.  Processing is paused until memory usage drops below the low watermark to prevent thrashing.

Avoids OOM errors during indexing by proactively managing memory usage.
@nikolap-dat

Copy link
Copy Markdown

Hey @macols77. Is it possible to pass to Titan, exactly (in GBs) how much memory it should use, instead of it figuring out itself (by checking on which server it runs and then calculating ratio)? The use case is, for instance, when the Titan runs on k8s or some other PaaS platform where it sees the whole node memory instead of how much it is allocated to it (i.e. when k8s kills the pod).

@macols77 macols77 closed this Nov 28, 2025
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.

2 participants