Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Bug Fixes
returns a string which can be parsed back into the original node.
(Peter Barna, Adam Schwartz)

* GITHUB#15133: Take the FST suffix cache into account when reporting FST ramBytesUsed (Anh Dung Bui)

* GITHUB#14847: Allow Faiss vector format to index >2GB of vectors per-field per-segment by using MemorySegment APIs
(instead of ByteBuffer) to copy bytes to native memory. (Kaival Parikh)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,9 @@ public long fstRamBytesUsed() {
if (dataOutput instanceof Accountable) {
ramBytesUsed += ((Accountable) dataOutput).ramBytesUsed();
}
if (suffixDedupCache != null) {
ramBytesUsed += suffixDedupCache.ramBytesUsed();
}
return ramBytesUsed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package org.apache.lucene.util.fst;

import java.io.IOException;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.ByteBlockPool;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.packed.PackedInts;
import org.apache.lucene.util.packed.PagedGrowableWriter;

Expand Down Expand Up @@ -48,7 +50,10 @@
* PagedGrowableWriter} to store the mapping, which allows efficient packing the hash & address long
* values, and uses {@link ByteBlockPool} to store the actual node content (arcs & outputs).
*/
final class FSTSuffixNodeCache<T> {
final class FSTSuffixNodeCache<T> implements Accountable {

private static final long BASE_RAM_BYTES =
RamUsageEstimator.shallowSizeOfInstance(FSTSuffixNodeCache.class);

// primary table -- we add nodes into this until it reaches the requested tableSizeLimit/2, then
// we move it to fallback
Expand Down Expand Up @@ -234,8 +239,18 @@ private long hash(FSTCompiler.UnCompiledNode<T> node) {
return h;
}

@Override
public long ramBytesUsed() {
long ramBytesUsed = BASE_RAM_BYTES + primaryTable.ramBytesUsed();
if (fallbackTable != null) {
ramBytesUsed += fallbackTable.ramBytesUsed();
}
return ramBytesUsed;
}

/** Inner class because it needs access to hash function and FST bytes. */
class PagedGrowableHash {
class PagedGrowableHash implements Accountable {

// storing the FST node address where the position is the masked hash of the node arcs
private PagedGrowableWriter fstNodeAddress;
// storing the local copiedNodes address in the same position as fstNodeAddress
Expand Down Expand Up @@ -485,5 +500,12 @@ private FST.BytesReader getBytesReader(long nodeAddress, long hashSlot) {
bytesReader.setPosDelta(nodeAddress - localAddress);
return bytesReader;
}

@Override
public long ramBytesUsed() {
return copiedNodes.ramBytesUsed()
+ fstNodeAddress.ramBytesUsed()
+ copiedNodeAddress.ramBytesUsed();
}
}
}
Loading