Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/neural-vision-roadmap #170 +/- ##
==============================================================
- Coverage 81.15% 79.00% -2.16%
==============================================================
Files 6 6
Lines 1348 1348
==============================================================
- Hits 1094 1065 -29
- Misses 254 283 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 14, 2026
Eliminate avoidable per-invocation AST reparsing, token-tree walks, and short-lived heap allocations across archmage-macros: - Skip non-#[cfg] attributes (such as doc comments and #[inline]) in drop_attrs_equal_to before formatting attribute tokens to String, and short-circuit when the guard is empty or no #[cfg] attribute exists. - Guard Self/self token-stream rewrites in #[arcane(_self = Type)] and #[autoversion(in_trait, _self = Type)] with tokens_contain_ident, and skip unrelated group subtrees in replace_self_value_in_tokens. - Inspect _self = Type directly via find_token_in_self_type and check_single_token_param instead of cloning syn::Signature and running parse_quote! on every receiver boundary. - Emit #[inline], #[target_feature], #[allow(...)], and ::archmage::* token paths directly into TokenStream without parse_quote! or syn::parse_str, and avoid cloning function bodies in attune proof wrappers. - Replace Ident::to_string() keyword/registry dispatches and small per-call Vec buffers with stack-backed with_ident_str ([u8; 64]), &'static str token/trait lookups, borrowed TokenTypeInfo<'a>, and safe inline SmallVec<T, N>.
lilith
force-pushed
the
perf/macro-hotpaths
branch
from
November 14, 2026 08:20
f53a367 to
bf379d5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminates avoidable per-invocation AST reparsing, redundant token-tree walks, and short-lived heap allocations across
archmage-macros(PR 1 of 3 in the compile-time optimization stack):drop_attrs_equal_to): Skip non-#[cfg]attributes (doc comments,#[inline], lint attributes) before formatting attribute tokens toString, and short-circuit immediately when the guard is empty or no#[cfg]attribute is present.Self/selftoken walks: Gatereplace_self_in_tokensandreplace_self_value_in_tokensbehindtokens_contain_identin#[arcane(_self = Type)]and#[autoversion(in_trait, _self = Type)], and skip unrelated delimited groups insidereplace_self_value_in_tokens.parse_quote!/syn::parse_stron hot paths): Emit#[inline],#[target_feature(enable = ...)],#[allow(...)], and::archmage::*token paths directly intoTokenStream(InlinePolicy::tokens,colon_path_tokens), inspect_self = Typeviafind_token_in_self_typewithout cloningsyn::Signature+parse_quote!, and avoid cloning function bodies inattuneproof wrappers.Ident::to_string()keyword/registry dispatches and small per-callVecbuffers with stack-backedwith_ident_str([u8; 64]),'statictoken/trait string slices, borrowedTokenTypeInfo<'a>, and safe inlineSmallVec<T, N>.Measured Impact (default
opt-level = 0, 20-thread Linux x86_64)Per-invocation allocations (
expansion_tests::profile_allocations)#[arcane]302(15,525 B)261(12,080 B)#[rite]231(12,245 B)182(8,794 B)#[attune]direct family393(14,854 B)299(10,812 B)#[attune(all)]1,237(45,403 B)942(30,943 B)#[attune]composed1,601(57,214 B)1,282(40,952 B)#[magetypes]1,859(69,687 B)1,700(57,721 B)#[autoversion]1,272(55,933 B)1,062(40,890 B)Crate expansion (
rustc -Ztime-passes, median of 5 runs)macro_expand_cratemacro_expand_cratemagetypes --features "std avx512"0.219 s0.193 s#[arcane]functions + 3,000 doc lines0.219 s0.193 s#[attune(_*, dispatch)]families0.456 s0.378 sVerification
cargo test -p archmage-macros --features avx512(164 unit +raw_snapshotsbyte-exact expansion tests)cargo test --features "std avx512"(allmacrotest,trybuildcompile-fail UI tests,soundness_exploits,attune_*, andmagetypessuites)cargo clippy -p archmage-macros --all-targets --features avx512 -- -D warningscargo run -p xtask -- validate-registry,validate,soundness