You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LSMTreeIndexCursor.fetchNext() allocates an ArrayList, a LinkedHashMap and a HashSet per key group, i.e. per row on a unique-index scan #6944
LSMTreeIndexCursor.fetchNext() allocates three collections per key group. On a unique-index scan a key group is one row, so a full range scan allocates an ArrayList, a LinkedHashMap and a HashSet per row, on the hottest read path in the engine.
Where (HEAD c1785ced6)
engine/src/main/java/com/arcadedb/index/lsm/LSMTreeIndexCursor.java:540-579, per iteration of the key-group loop:
The number of live RIDs per key is 1 for a unique index and small for most non-unique ones, so all three are sized far above what they hold, and all three die immediately.
Cost
Three allocations plus their internal arrays (ArrayList's Object[], LinkedHashMap's Node[] and one Node per put, HashSet's backing HashMap) per emitted row, i.e. roughly 6-8 objects per row where the useful output is one IndexCursorEntry. On a 1M-row indexed range scan that is on the order of 7M short-lived objects, all in the young generation, against a codebase whose own CLAUDE.md states "always bear in mind PERFORMANCE ... prefer using arrays of primitives to List of Objects".
Suggested fix
Hoist the three containers to fields and clear() them per group rather than reallocating - the cursor is single-threaded and each group's contents are consumed before the next group starts. For the common single-RID case, a fast path that skips the maps entirely (when the group holds one value and it is not a tombstone, emit directly) would remove the allocations altogether for unique-index scans.
I would treat the fields-and-clear version as the safe change and the fast path as the optional follow-up.
Scope / confidence
Medium-high on the cost argument, which is a straight read of the allocation sites; the actual throughput gain depends on how much of the scan cost is page decoding versus allocation, so it is worth a JMH check before and after. Note this is the same method as the correctness issue filed separately about the transaction overlay's REMOVE entries being ignored - if both are addressed, doing the correctness fix first is the right order, since it changes what state the loop has to keep.
Unique-index range scans no longer allocate extra collections per row - the scan reuses the same working buffers instead of creating new ones for every key, reducing garbage-collector pressure on large scans.
\n---\n❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
Activity
review: release notes entry, tighten a loose test precondition
Merge pull request #6963 from ArcadeData/fix/6943-6944-6945-triangle-…
lvca commentedon Sep 1, 2026
Fixed in #6963 (merged).
Unique-index range scans no longer allocate extra collections per row - the scan reuses the same working buffers instead of creating new ones for every key, reducing garbage-collector pressure on large scans.
\n---\n❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
ruispereira commentedon Sep 1, 2026
Re-validated against
mainat8cfac2923: confirmed fixed, including every part this issue listed. No follow-up needed.fix(ArcadeData#6943,ArcadeData#6944,ArcadeData#6945): triangle-op ove…