Files
doris/fe
Yongqiang YANGandClaude Opus 4.6 391412885f [Enhancement](memory) Add ConcurrentLong2ObjectHashMap and ConcurrentLong2LongHashMap (#61332)
## Summary

Add two thread-safe primitive-key concurrent hash maps built on
fastutil, designed as drop-in replacements for `ConcurrentHashMap<Long,
V>` and `ConcurrentHashMap<Long, Long>` in memory-sensitive FE paths.

- **`ConcurrentLong2ObjectHashMap<V>`** — replaces
`ConcurrentHashMap<Long, V>`
- **`ConcurrentLong2LongHashMap`** — replaces `ConcurrentHashMap<Long,
Long>`

### Why

`ConcurrentHashMap<Long, V>` costs ~64 bytes per entry due to Long
boxing, Node wrapper, and segment overhead. These fastutil-based maps
reduce that to ~16 bytes per entry — a **4x memory reduction**.

In Doris FE, several critical data structures use
`ConcurrentHashMap<Long, V>` at tablet/partition scale (millions of
entries), making this a significant memory optimization opportunity.

### Design

- **Segment-based locking** (default 16 segments) for concurrent
throughput, similar to Java 7's ConcurrentHashMap design
- Full `Map` interface compatibility for drop-in replacement
- Atomic operations: `putIfAbsent`, `computeIfAbsent`, `replace`,
`remove(key, value)`
- Thread-safe iteration via snapshot-based
`entrySet()`/`keySet()`/`values()`

### Memory comparison

| Collection | Per-entry overhead | 1M entries |
|------------|-------------------|------------|
| `ConcurrentHashMap<Long, V>` | ~64 bytes | ~61 MB |
| `ConcurrentLong2ObjectHashMap<V>` | ~16 bytes | ~15 MB |
| `ConcurrentHashMap<Long, Long>` | ~80 bytes | ~76 MB |
| `ConcurrentLong2LongHashMap` | ~16 bytes | ~15 MB |

## Test plan

- [x] `ConcurrentLong2ObjectHashMapTest` — 432 lines covering
put/get/remove, putIfAbsent, computeIfAbsent, replace, concurrent writes
from multiple threads, iteration consistency, empty map edge cases
- [x] `ConcurrentLong2LongHashMapTest` — 455 lines covering CRUD,
default value semantics, concurrent operations, atomic operations,
iteration, edge cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 19:25:40 -07:00
..
…
…
…

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# fe-common

This module is used to store some common classes of other modules.

# spark-dpp

This module is Spark DPP program, used for Spark Load function.
Depends: fe-common

# fe-core

This module is the main process module of FE.
Depends: fe-common, spark-dpp