|
10 | 10 | //! - [`validate_with_context`] -- validate with rule overrides or wrapper depth |
11 | 11 | //! - [`all_rules`] -- list the full 108-rule catalog |
12 | 12 | //! |
| 13 | +//! # Performance — allocator recommendation |
| 14 | +//! |
| 15 | +//! `vastlint-core` builds an owned document tree on every call (one heap |
| 16 | +//! allocation per XML element, attribute, and text node). Under concurrent |
| 17 | +//! load the system allocator becomes a bottleneck because all threads compete |
| 18 | +//! for a shared free-list lock. |
| 19 | +//! |
| 20 | +//! Switching to [`mimalloc`](https://docs.rs/mimalloc) in your **binary** |
| 21 | +//! crate eliminates this contention and gives dramatically better throughput |
| 22 | +//! at high concurrency, especially for larger documents: |
| 23 | +//! |
| 24 | +//! ```toml |
| 25 | +//! # Cargo.toml (your binary, not a library crate) |
| 26 | +//! [dependencies] |
| 27 | +//! mimalloc = { version = "0.1", default-features = false } |
| 28 | +//! ``` |
| 29 | +//! |
| 30 | +//! ```rust,ignore |
| 31 | +//! // src/main.rs |
| 32 | +//! use mimalloc::MiMalloc; |
| 33 | +//! #[global_allocator] |
| 34 | +//! static GLOBAL: MiMalloc = MiMalloc; |
| 35 | +//! ``` |
| 36 | +//! |
| 37 | +//! Measured on Apple M-series (10 threads, 339 KB VAST documents, 100k calls): |
| 38 | +//! |
| 39 | +//! | Allocator | Throughput | avg latency | p99 latency | |
| 40 | +//! |---|---|---|---| |
| 41 | +//! | system (default) | 7,966 tags/s | 1,246 µs | 24,260 µs | |
| 42 | +//! | mimalloc | 57,936 tags/s | 171 µs | 912 µs | |
| 43 | +//! |
| 44 | +//! **+628% throughput, p99 drops 26×.** |
| 45 | +//! |
| 46 | +//! > ⚠️ Do **not** set a global allocator in a library crate — it would |
| 47 | +//! > override the allocator for any host process that links you (Go, Python, |
| 48 | +//! > Ruby runtimes, etc.), which can cause heap corruption. |
| 49 | +//! |
13 | 50 | //! # Quick start |
14 | 51 | //! |
15 | 52 | //! ```rust |
|
0 commit comments