[package]
name = "masstree"
version = "0.5.6"
edition = "2024"
rust-version = "1.92.0"
authors = ["consistent-milk12"]
description = "A high-performance concurrent ordered map (trie of B+trees)"
license = "MIT"
repository = "https://github.com/consistent-milk12/masstree"
documentation = "https://docs.rs/masstree"
keywords = [
	"data-structures",
	"concurrent",
	"ordered-map",
	"range-scans",
	"trie",
]
categories = ["data-structures", "concurrency", "database-implementations"]
readme = "README.md"
include = ["src/**/*", "Cargo.toml", "LICENSE", "README.md"]

[features]
default = []
# Alternative global allocators for benchmarking
mimalloc = ["dep:mimalloc"]
# When disabled (default), all tracing calls compile to no-ops with zero overhead.
# When enabled, auto-initializes a subscriber that writes NDJSON logs to logs/masstree.jsonl.
# Respects RUST_LOG env var (default: info). Set MASSTREE_LOG_CONSOLE=0 to disable console.
tracing = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-appender"]
# Enable CLI tools (divan_parser, criterion_summary). Not needed for library usage.
bins = [
	"dep:serde_json",
	"dep:serde",
	"dep:chrono",
	"dep:clap",
	"dep:comfy-table",
	"dep:regex",
]
true-inline = [] # Enable true-inline value storage
debug-routing = [] # Enable routing debug output for bug investigation
insert-stats = [] # Enable insert retry statistics collection

[dependencies]
seize = "0.5.1"
parking_lot = "0.12.5"
portable-atomic = "1.13.0"
arrayvec = "0.7.6"
static_assertions = "1.1.0"
rustc-hash = "2.1.1"
crossbeam-queue = "0.3.12"

# Optional allocators (enabled via features)
mimalloc = { version = "0.1.48", optional = true }

# Platform-specific dependencies
[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2.180"

# Optional tracing (enabled via features) - zero overhead when disabled
# "attributes" enables #[instrument] for function-level tracing
tracing = { version = "0.1.44", features = ["attributes"], optional = true }
tracing-subscriber = { version = "0.3.22", features = [
	"env-filter",
	"fmt",
	"json",
], optional = true }
tracing-appender = { version = "0.2.4", optional = true }

# Optional CLI tool dependencies (enabled via `bins` feature)
serde_json = { version = "1.0.149", optional = true }
serde = { version = "1.0.228", features = ["derive"], optional = true }
chrono = { version = "0.4.43", optional = true }
clap = { version = "4.5.54", features = ["derive"], optional = true }
comfy-table = { version = "7.2.2", optional = true }
regex = { version = "1.12.2", optional = true }

[dev-dependencies]
clap = { version = "4.5.54", features = ["derive"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
divan = "0.1.21"
proptest = "1.9.0"
loom = "0.7.2"
shuttle = "0.8.1"
papaya = "0.2.3"
dashmap = "6.1.0"
congee = "0.4.1"
crossbeam-skiplist = "0.1.3"
crossbeam-epoch = "0.9.18"
rand = "0.9.2"
rand_chacha = "0.9.0"
indexset = { version = "0.14.0", features = ["concurrent"] }
scc = "3.4.10"
sdd = "4.5.3"
tracing = { version = "0.1.44", features = ["attributes"] }
tracing-subscriber = { version = "0.3.22", features = [
	"env-filter",
	"fmt",
	"json",
	"parking_lot",
] }
criterion = { version = "0.8.1", features = [
	"html_reports",
	"csv_output",
	"real_blackbox",
] }
iai-callgrind = "0.16.1"

# Examples dependencies
rayon = "1.11.0"
core_affinity = "0.8.3"
tokio = { version = "1.49.0", features = ["full"] }

[lints.rust]
# Allow loom and shuttle cfg for deterministic concurrency testing
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(shuttle)'] }

# Safety and correctness
unsafe_op_in_unsafe_fn = "warn"
missing_docs = "deny"                                       # Enforce documentation for public API
missing_debug_implementations = "warn"
rust_2024_compatibility = { level = "warn", priority = -1 }

# Future-proofing
future_incompatible = { level = "warn", priority = -1 }
nonstandard_style = { level = "warn", priority = -1 }

# Unused code detection
unused = { level = "warn", priority = -1 }

[lints.clippy]
# Clippy lint groups
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }

# Performance-critical code policy:
# - These are WARN not DENY to allow targeted #[allow(...)] with justification
# - Each allowed instance must have a SAFETY or INVARIANT comment
# - Prefer debug_assert! + direct access over .get().unwrap() chains
unwrap_used = "warn"
expect_used = "warn"
panic = "warn"
indexing_slicing = "warn"

# Allow in hot paths with justification (use #[allow] locally):
# - missing_panics_doc: Internal functions may panic on invariant violation
# - missing_errors_doc: Not using Result for internal errors

# Pedantic lints - keep most, allow noisy ones
module_name_repetitions = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"

# These SHOULD be enforced for quality
# must_use_candidate = "warn"  # Default from pedantic
# doc_markdown = "warn"        # Default from pedantic

[profile.dev]
opt-level = 0
debug = true
debug-assertions = true
overflow-checks = true
incremental = true

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = "fat"
panic = "abort"
codegen-units = 1
strip = "symbols"

[profile.release-with-debug]
inherits = "release"
debug = 2
strip = "none"
lto = false

# Profiling profile - optimized for flamegraph/perf
# Frame pointers required for accurate stack traces
[profile.profiling]
inherits = "release"
debug = 2
strip = "none"
lto = false

# Force frame pointers in our code (dependencies need RUSTFLAGS)
[profile.profiling.package."*"]
debug = true

[profile.bench]
inherits = "release"

[[bench]]
name = "concurrent_maps15"
harness = false

[[bench]]
name = "concurrent_read_write"
harness = false

[[bench]]
name = "concurrent_read_write_scaled"
harness = false

[[bench]]
name = "concurrent_read_write_masstree"
harness = false

[[bench]]
name = "concurrent_read_write_masstree_scaled"
harness = false

[[bench]]
name = "concurrent_masstree15"
harness = false

[[bench]]
name = "range_masstree15"
harness = false

[[bench]]
name = "cpp_comp"
harness = false

[[bench]]
name = "mttest"
harness = false

[[bench]]
name = "extreme_stress"
harness = false

[[bench]]
name = "extreme_stress_15_crit"
harness = false

[[bench]]
name = "concurrent_masstree15_crit"
harness = false

[[bench]]
name = "range_masstree15_crit"
harness = false

[[bench]]
name = "iai_masstree"
harness = false

[[bench]]
name = "rwlock_btreemap_vs_masstree15"
harness = false

[[bench]]
name = "rwlock_btreemap_vs_masstree15_inline"
harness = false

# =========================================================================
# Examples
# =========================================================================

[[example]]
name = "basic_usage"
path = "examples/basic_usage.rs"

[[example]]
name = "rayon_parallel"
path = "examples/rayon_parallel.rs"

[[example]]
name = "tokio_async"
path = "examples/tokio_async.rs"

[[example]]
name = "url_cache"
path = "examples/url_cache.rs"

[[example]]
name = "session_store"
path = "examples/session_store.rs"

# =========================================================================
# Internal Binaries (not part of the library)
# =========================================================================

[[bin]]
name = "divan_parser"
path = "bin/divan_parser.rs"
required-features = ["bins"]
