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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Per-query LRU capacity options for the incremental database (spec §11.X).
//!
//! [`DatabaseOptions`] is passed to [`crate::workspace::Database::with_options`]
//! at construction time; it cannot be mutated after the database is created.
//!
//! ## Default capacities
//!
//! | Query layer | Default cap | Notes |
//! |------------------|------------|-------------------------------------|
//! | `parse_cst` | 256 | Parse + HIR (fast; keep warm) |
//! | `sema` | 256 | Name-res + semantic passes |
//! | `plan` | 256 | Logical plan |
//! | `formatted` | 256 | Formatter output |
//! | `ast` | uncapped | Zero-cost view over parse output |
//! | `diagnostics` | uncapped | Union of parse + sema diags |
//!
//! ## Salsa LRU integration
//!
//! Salsa 0.26 requires the `lru` capacity to be declared at compile time via
//! `#[salsa::tracked(lru = N)]`. The compile-time constant is set to the
//! default of 256. At construction time, if [`DatabaseOptions`] carries a
//! different value, [`crate::workspace::Database::with_options`] calls the runtime
//! `set_lru_capacity` API generated by Salsa to adjust the cap. When the
//! options match the compile-time default the runtime call is elided.
/// Per-query LRU capacity configuration for [`crate::workspace::Database`].
///
/// Pass to [`crate::workspace::Database::with_options`] at construction.
/// The options are immutable after construction — Salsa does not support
/// changing LRU capacity mid-session.
///
/// # Example
///
/// ```rust,ignore
/// use cyrs_db::{Database, DatabaseOptions};
///
/// let opts = DatabaseOptions { parse_lru: 512, ..DatabaseOptions::default() };
/// let db = Database::with_options(opts);
/// ```