1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Global allocator selection for the `liter-llm` CLI binary.
//!
//! Exactly one of the following is selected at compile time:
//!
//! | Feature | Allocator |
//! |--------------|------------------------------------|
//! | `mimalloc` | Microsoft's mimalloc |
//! | `jemalloc` | jemalloc via tikv-jemallocator |
//! | *(neither)* | System allocator (Rust default) |
//!
//! Enabling both `mimalloc` and `jemalloc` simultaneously is a compile-time
//! error: the two `#[global_allocator]` attributes would conflict and Rustc
//! would reject the crate. Cargo feature resolution does not prevent this
//! automatically, so callers must not enable both.
// Only one allocator is active per build; the unused imports below are
// conditional on features that are mutually exclusive by convention.
// SAFETY: `mimalloc::MiMalloc` is a stateless ZST that implements
// `GlobalAlloc` correctly. The crate guarantees thread-safety and the
// allocator does not impose any alignment constraints beyond those required
// by the Rust allocator contract.
static ALLOCATOR: MiMalloc = MiMalloc;
// SAFETY: `tikv_jemallocator::Jemalloc` is a stateless ZST that implements
// `GlobalAlloc` by delegating to jemalloc. Thread-safety and allocator
// contract compliance are guaranteed by the upstream crate.
static ALLOCATOR: Jemalloc = Jemalloc;