edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB5c8eff8Tahinli2 months ago2949 commits
| 1 | //! Process-constant snapshot of the environment (lane-perf1). |
| 2 | //! |
| 3 | //! Every `EC_*` debug/trace flag in this crate is read on per-block, per-TU or |
| 4 | //! even per-MC-call paths, and `std::env::var*` is a `getenv` + `strlen` + |
| 5 | //! `CStr` validation every time: 11.6% of `decode_probe`'s self time. Nothing |
| 6 | //! in the crate or its tests calls `set_var` (`grep -rn set_var crates/ec-av1` |
| 7 | //! = 0 hits), so each name is a process constant and may be read once. |
| 8 | //! |
| 9 | //! [`env_flag!`] is the zero-syscall form for `is_some()`/`is_none()` checks: |
| 10 | //! it keeps one `LazyLock<bool>` per CALL SITE, so a hot check compiles to an |
| 11 | //! atomic load. [`var`] keeps the `Result<String, VarError>` shape of |
| 12 | //! `std::env::var` for the sites that want the value, off one snapshot map. |
| 13 | |
| 14 | use HashMap; |
| 15 | use VarError; |
| 16 | use LazyLock; |
| 17 | |
| 18 | static ENV: = new; |
| 19 | |
| 20 | /// `std::env::var`'s contract, served from the snapshot. Non-UTF-8 values are |
| 21 | /// dropped by `std::env::vars()`; the crate only reads `EC_*` flags and paths. |
| 22 | pub |
| 23 | |
| 24 | |
| 25 | |
| 26 | /// `true` iff `name` is present in the environment. Prefer [`env_flag!`] on |
| 27 | /// hot paths -- this one still hashes the name per call. |
| 28 | pub |
| 29 | |
| 30 | |
| 31 | |
| 32 | /// One `LazyLock<bool>` per call site: `std::env::var_os(N).is_some()` with no |
| 33 | /// syscall and no hashing after the first call. |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | pub use env_flag; |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 |