apache / apache/lucene

Default page/block sizes in the FST package can cause OOMs [LUCENE-5875]

Open
#6,937 8 comments 0 reactions 0 assignees View on GitHub
affects-version:4.9 legacy-jira-priority:Minor module:core/FSTs type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

We are building some fairly big FSTs (the biggest one having about 500M terms with an average of 20 characters per term) and that works very well so far.
The problem is just that we can use neither the "doShareSuffix" nor the "doPackFST" option from the builder since both would cause us to get exceptions. One beeing an OOM and the other an IllegalArgumentException for a negative array size in ArrayUtil.

The thing here is that we in theory still have far more than enough memory available but it seems that java for some reason cannot allocate byte or long arrays of the size the NodeHash needs (maybe fragmentation?).

Reducing the constant in the NodeHash from 1<<30 to e.g. 27 seems to fix the issue mostly. Could e.g. the Builder pass through its bytesPageBits to the NodeHash or could we get a custom parameter for that?

The other problem we run into was a NegativeArraySizeException when we try to pack the FST. It seems that we overflowed to 0x80000000. Unfortunately I accidentally overwrote that exception but I remember it was triggered by the GrowableWriter for the inCounts in line 728 of the FST. If it helps I can try to reproduce it.

---
Migrated from [LUCENE-5875](https://issues.apache.org/jira/browse/LUCENE-5875) by Christian Ziech, updated Aug 11 2014

Contributor guide

Open the contributing guide

Research direction

Start with the FST builder paths for doShareSuffix and doPackFST, then inspect the NodeHash page-size constant and ArrayUtil allocation failures. Read the GrowableWriter usage around FST line 728 and try to reproduce the reported OOM, negative array-size, and overflow failures; done means large FSTs no longer hit these exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.