apache / apache/lucene

NRT Caching Dir to allow for exact memory usage, better buffer allocation and "global" cross indices control [LUCENE-3425]

Open
#4,498 11 comments 0 reactions 0 assignees View on GitHub
affects-version:3.4 affects-version:4.0-ALPHA legacy-jira-fix-version:4.9 legacy-jira-fix-version:6.0 legacy-jira-priority:Major module:core/index type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

A discussion on IRC raised several improvements that can be made to NRT caching dir. Some of the problems it currently has are:

1. Not explicitly controlling the memory usage, which can result in overusing memory (for example, large new segments being committed because refreshing is too far behind).
2. Heap fragmentation because of constant allocation of (probably promoted to old gen) byte buffers.
3. Not being able to control the memory usage across indices for multi index usage within a single JVM.

A suggested solution (which still needs to be ironed out) is to have a BufferAllocator that controls allocation of byte[], and allow to return unused byte[] to it. It will have a cap on the size of memory it allows to be allocated.

The NRT caching dir will use the allocator, which can either be provided (for usage across several indices) or created internally. The caching dir will also create a wrapped IndexOutput, that will flush to the main dir if the allocator can no longer provide byte[] (exhausted).

When a file is "flushed" from the cache to the main directory, it will return all the currently allocated byte[] to the BufferAllocator to be reused by other "files".

---
Migrated from [LUCENE-3425](https://issues.apache.org/jira/browse/LUCENE-3425) by Shay Banon (@kimchy), 1 vote, updated May 09 2016

Contributor guide

Open the contributing guide

Research direction

Start by understanding the NRT caching directory and its proposed BufferAllocator, including the wrapped IndexOutput and main-directory flush path described in the issue. Determine how allocation caps, cross-index sharing, buffer reuse, and exhaustion-triggered flushing should work; done means the design is agreed and these behaviors are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.