Agent skill

Rust Performance

by pikax in pikax/verter

Rust performance optimization patterns: batch operations, allocation hierarchy, object pooling, CodeTransform API for vertercompiler

MITAuto-check passedDevelopment

Install Rust Performance

skills CLI
$ npx skills add pikax/verter --skill rust-performance -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pikax/verter rust-performance --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pikax/verter.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/rust-performance .claude/skills/rust-performance && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rust-performance
GitHub stars
112
Token cost
~2.8k tokens
SKILL.md length
981 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

Rust performance optimization patterns: batch operations, allocation hierarchy, object pooling, CodeTransform API for vertercompiler

  • Works in 11 steps: Batch Over Incremental → Allocation Hierarchy → Reusable Buffer Pattern → …
  • Tasks that involve Performance optimization
  • SKILL.md covers 1. Batch Over Incremental, 2. Allocation Hierarchy, 3. Reusable Buffer Pattern and 4. Object Pooling, plus 8 more sections
  • Calls pnpm

What it does

Rust Performance is an agent skill from pikax/verter. Rust performance optimization patterns: batch operations, allocation hierarchy, object pooling, CodeTransform API for vertercompiler

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Performance optimization. It works with Rust. The repository describes itself as: Fast Rust-powered compiler, semantic extraction, and LSP for component frameworks. The licence is MIT.

When your agent uses it

  • Tasks that involve Performance optimization

Example prompts

  • “/rust-performance”

Workflow steps

11 steps, taken from the step headings in SKILL.md.

  1. Batch Over Incremental
  2. Allocation Hierarchy
  3. Reusable Buffer Pattern
  4. Object Pooling
  5. Borrow Source Instead of Cloning
  6. Static Fast Paths
  7. Pre-size Collections
  8. Reduce Work, Not Just Speed
  9. Bulk-Copy String Processing
  10. Benchmarking Methodology
  11. CodeTransform Optimization History

What it can do on your machine

Read from SKILL.md and the folder at commit 98aba28. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rust Performance loads about 2.8k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 981 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pikax/verter at commit 98aba28, republished under its MIT licence (© pikax). 981 words, ~2,797 tokens.

Download SKILL.mdSave it as .claude/skills/rust-performance/SKILL.md (or your agent's skills folder).
name
rust-performance
description
Rust performance optimization patterns: batch operations, allocation hierarchy, object pooling, CodeTransform API for verter_compiler

Rust Performance Guide

Principles for writing performant Rust in verter_compiler.

1. Batch Over Incremental

CodeTransform operations like overwrite() and prepend_left() each walk the chunk list in O(n). Calling them in a loop is O(n*N). Collect operations into Vecs and apply with batch APIs:

  • batch_overwrite(ops: &[(u32, u32, &str)]) — sorted overwrites in one chunk-list pass
  • batch_prepend_left_static(ops: &[(u32, &str)]) — sorted inserts in one pass
rust
// BAD: O(n) per call × N calls
for (start, end, content) in replacements {
    code_transform.overwrite(start, end, content);
}

// GOOD: O(n+m) single pass
replacements.sort_by_key(|(start, _, _)| *start);
code_transform.batch_overwrite(&replacements);

If calling a mutating method in a loop, ask whether operations can be collected and applied in one traversal.

2. Allocation Hierarchy

Prefer allocations in this order (fastest to slowest):

  1. &'static str — zero-cost, compile-time constants
  2. &'alloc str via code_transform.alloc_str(buf) — OXC bump allocator, freed in bulk
  3. &str from ctx.input[start..end] — zero-cost slice of source
  4. Reusable &mut String buffer — amortized cost via capacity reuse
  5. String — heap-allocated, avoid in hot paths
NeedUse
Known constant value&'static str
Generated text that outlives current functioncode_transform.alloc_str(buf) → &'alloc str
Substring of source input&ctx.input[start..end]
Temporary text build-upShared &mut String buffer (see below)
Truly owned, long-lived, mutable textString

3. Reusable Buffer Pattern

Codegen generators (e.g., VdomTemplateGenerator) keep a buf: String field. Use std::mem::take to temporarily take ownership — avoids borrow conflicts with other self fields:

rust
// Take buffer — avoids per-element heap allocation:
let mut buf = std::mem::take(&mut self.buf);
process_element(&mut buf, ...);
self.buf = buf; // return — retains capacity for next element

// In called functions, accept buf: &mut String.
// Use `buf` directly, not `&mut buf` (it's already &mut String).

After building text in buf, persist via bump allocator:

rust
buf.clear();
buf.push_str("_createVNode(");
buf.push_str(tag);
buf.push(')');
let s: &'alloc str = code_transform.alloc_str(&buf);
pending_overwrites.push((start, end, s));
Save/Truncate for Nested Buffer Use

To build a temporary string inside a function already using buf, use save/truncate instead of allocating a second buffer:

rust
let saved = buf.len();
buf.push_str("{ ");
for (i, prop) in props.iter().enumerate() {
    if i > 0 { buf.push_str(", "); }
    buf.push_str(prop);
}
buf.push_str(" }");
let result = code_transform.alloc_str(&buf[saved..]);
buf.truncate(saved); // restore buf to previous state

Avoids per-element heap allocation when building intermediate strings like hoisted props.

4. Object Pooling

StateStack (per-element state during tree walk) contains multiple Vec fields. Pool instead of allocating/dropping per element:

rust
// Take from pool — Vecs retain capacity from previous use:
fn take_state(&mut self, id: u32) -> StateStack {
    if let Some(mut s) = self.state_pool.pop() {
        s.reset(id);  // .clear() on all Vecs — retains capacity
        s
    } else {
        StateStack { id, ..Default::default() }
    }
}

// Return to pool after element close:
fn return_state(&mut self, state: StateStack) {
    self.state_pool.push(state);
}

Apply to any struct with inner collections repeatedly created/dropped in a loop. Vec::clear() retains allocated capacity.

5. Borrow Source Instead of Cloning

ctx.input holds the full source text. Borrow slices directly instead of cloning:

rust
// BAD: heap allocation just to read
let name: String = ctx.input[start..end].to_string();
buf.push_str(&name);

// GOOD: zero-cost borrow
let name: &str = &ctx.input[start as usize..end as usize];
buf.push_str(name);

For struct fields, prefer &'alloc str (bump-allocated) when the struct's lifetime allows. If adding a lifetime would cascade through too many types, String is acceptable.

6. Static Fast Paths

For functions frequently returning one of a small set of constants, return &'static str directly. &'static str coerces to &'alloc str, so static constants can be used anywhere bump-allocated strings are expected.

rust
// Common close strings — no bump allocation needed
let close_str: &'alloc str = if patch_flag.0 == 0 && !is_block_root {
    if needs_array { "])" } else { ")" }  // &'static str coerces to &'alloc str
} else {
    // Rare case: build dynamically
    buf.clear();
    write_patch_flag_suffix(buf, patch_flag, &dynamic_props);
    code_transform.alloc_str(buf)
};

7. Pre-size Collections

Use with_capacity when expected size is known or estimable:

rust
pending_overwrites: Vec::with_capacity(512),
pending_prepend_lefts: Vec::with_capacity(256),
buf: String::with_capacity(128),

Over-estimating slightly is cheaper than re-allocating.

8. Reduce Work, Not Just Speed

Once allocation and batching are optimized, further gains come from doing less work:

  • Skip expensive operations for trivial cases — e.g., don't sort prop indices when all props have the same priority, don't run OXC parser for a bare identifier binding
  • Early-return fast paths — e.g., skip Vec allocation + sort + clone when all element props are static (no directives)
  • Merge redundant operations — e.g., combine two adjacent overwrites (tag name + props) into a single overwrite when both are known at the same time
  • Cache/deduplicate repeated computations — e.g., resolved_components_set for component dedup
  • Short-circuit early when results are known

9. Bulk-Copy String Processing

When processing strings character-by-character (e.g., escaping), prefer a bulk-copy pattern that tracks unmodified regions and copies them in one push_str call:

rust
fn escape_js_string_into(buf: &mut String, s: &str) {
    let mut last_copy_end = 0;
    for (i, ch) in s.char_indices() {
        let replacement = match ch {
            '"' => "\\\"",
            '\\' => "\\\\",
            '\n' => "\\n",
            _ => continue,
        };
        buf.push_str(&s[last_copy_end..i]); // bulk copy unmodified region
        buf.push_str(replacement);
        last_copy_end = i + ch.len_utf8();
    }
    buf.push_str(&s[last_copy_end..]); // copy remaining
}

10. Benchmarking Methodology

When comparing against another compiler (e.g., Vue's @vue/compiler-sfc):

  • Ensure feature parity — if one compiler generates source maps and the other doesn't, you're not comparing the same work
  • Source maps are expensive — VLQ encoding + JSON serialization + base64 can consume 30-40% of compile time
  • NAPI overhead is fixed — allocator creation + JS↔Rust marshalling adds ~7μs per call
  • Profile in release mode — debug builds are 10-50x slower
Agent Profiling via MCP (hotpath)
bash
pnpm run profile:hotpath:mcp    # Start with MCP endpoint at http://localhost:6771/mcp
pnpm run profile:hotpath        # Timing hotspots (no MCP)
pnpm run profile:hotpath:alloc  # Timing + allocation hotspots

Agent MCP config template: mcp/hotpath.mcp.json

11. CodeTransform Optimization History

Show full SKILL.md (405 more words)Show less
Successful Optimizations (Committed)

A. Fast-path overwrite() for single Original chunk — When the overwritten range falls within a single Original chunk, bypass the general SmallVec<[Chunk; 4]> + Vec::splice path. Use direct Vec::insert (1-2 calls) for the 4 sub-cases.

B. Eliminate build_string first pass via output_delta tracking — Added output_delta: i64 field tracking running difference between inserted and removed content. build_string() uses it for String::with_capacity, eliminating the first chunk-iteration pass. ~19% improvement on build_string/2000.

C. Merge move_wrapped split + identification into single pass — Replaced 3 separate linear scans with a single forward while loop.

E-H. Scratch Vec pre-allocation, push_u32 direct digit computation, format_patch_flag static strings, provided_locals Option optimization — Combined: compile aggregate -9.4%.

K-N. format_scope_close → &'static str, children.rs text run static constants, condition_scope_close, build_child_records prefix optimization — Combined: no_sourcemap -5.0%, with_sourcemap -8% to -17%.

Failed/Reverted Optimizations

D. PositionSweep for monotonic positions — Changing emit_mapped_content's function signature caused +8.7% regression on unmodified files. Binary search with ~10 comparisons is already in the CPU branch predictor's sweet spot.

I. BindingContext clone elimination — Inconclusive due to 20-33% system noise. BindingContext clone cost is small (one FxHashSet per expression).

O. Vec<ChildRecord> reuse via std::mem::take — No measurable improvement. Small Vec allocations (1-10 items) are already efficient.

Where NOT to Look for Further Gains
AreaWhy it won't help
offset_to_line_col binary searchAlready fast for typical file sizes
emit_mapped_content signatureChanging parameters causes LLVM optimization regressions
memchr_iter in source mapAlready optimal — memchr uses SIMD
Vec<ChildRecord> reuseSmall Vec allocations (1-10 items) are already fast
resolve_simple_expr per-expression String~10-20 calls per component, ~20 bytes each — below noise floor
Component resolution String allocationPer-component, unavoidable (tag names are dynamic)

Anti-Patterns

PatternProblemFix
overwrite()/prepend_left() in a loopO(n) per callCollect into Vec + batch API
buf.clone() for storageHeap alloc per clonecode_transform.alloc_str(buf)
.to_string() on ctx.input slicesUnnecessary heap copy&ctx.input[start..end]
Fresh Vec-heavy structs per iterationAlloc/dealloc churnPool + reset() with .clear()
Instant::now() unconditionallyPanics in WASM#[cfg(not(target_arch = "wasm32"))] guard
SmallVec with large types (>64B) in Box'd structsInflates allocation size, 40-50% regressionKeep Vec
Vec<String> for bump-allocatable contentPer-element heap allocVec<&'alloc str> + save/truncate
Explicit is_sorted check before sortRust's TimSort already detects sorted runsJust call .sort_by_key()
Changing hot function signaturesCauses LLVM optimization regressionsKeep hot function signatures stable
Linear sweep replacing binary search on <1K elementsBinary search already in CPU branch predictor sweet spotOnly consider at >10K elements
Reusing small Vecs (1-10 items)Allocator handles small allocations efficientlyOnly pool/reuse Vecs with >50 items

© pikax, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/rust-performance of pikax/verter.

Open the folder on GitHubat commit 98aba28

Compare with similar skills

Rust Performance next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rust Performance compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rust Performance this skillpikax/verter112—~2.8kAutomated safety check: PassMIT
Samplyvortex-data/vortex3.2k—~2.7kAutomated safety check: PassApache-2.0
Investigate User Bugcristicretu/diri424—~1.2kAutomated safety check: PassApache-2.0
Cppcrazyguitar/cppcheatsheet290—~1.8kAutomated safety check: PassMIT
Rust Profilingdiodeme/Gold-Band1431 repos~1.7kAutomated safety check: NotesAGPL-3.0
ProfilingShopify/rubydex363—~2.3kAutomated safety check: NotesCustom licence

Similar skills

  • Samply

    vortex-data/vortex

    Analyze Samply Firefox-profiler output, record focused profiles, summarize hot threads/stacks, inspect symbolication, and compare profile evidence before and after a performance change.

    3.2k GitHub stars~2.7k tokensUpdated today
    DevelopmentAuto-check passed
  • Investigate User Bug

    cristicretu/diri

    Investigate a bug a specific diri user hit (crash, hang, slowness, memory leak, blank or garbled terminal, spawn/resume/remote failure, copy/paste not working) from diri's telemetry with the…

    424 GitHub stars~1.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Cpp

    crazyguitar/cppcheatsheet

    Comprehensive C/C++ programming reference covering everything from C11-C23 and C++11-C++23, system programming, CUDA GPU computing, debugging tools, Rust interop, and advanced topics.

    290 GitHub stars~1.8k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Rust Profiling

    diodeme/Gold-Band

    Rust profiling skill for performance analysis. An agent skill from diodeme/Gold-Band.

    143 GitHub starsUsed in 1 repo~1.7k tokens
    DevelopmentAuto-check: notes
  • Profiling

    Shopify/rubydex

    Official

    Profile Rubydex indexer performance — CPU flamegraphs, memory usage, phase-level timing.

    363 GitHub stars~2.3k tokensUpdated 6 days ago
    DevelopmentAuto-check: notes
  • Review guidance for the speed of Oxc linter rules written in Rust: narrow node-kind checks, cheap tests first, deferred diagnostics and the smallest possible iteration.

    23k GitHub stars~1.1k tokensUpdated today
    DevelopmentAuto-check passed

More from pikax/verter

All 14 skills in this repo
  • Debug Tooling

    pikax/verter

    In-process backtrace watchdog + LLDB attach wrapper + release-dbg profile for diagnosing hangs and slow paths in Verter benches and binaries on Windows / macOS / Linux.

    112 GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Agent Prompts

    pikax/verter

    Generate copy-pasteable prompts for driving separate Claude Code sessions through refactor, review, or migration work.

    112 GitHub stars~5k tokensUpdated today
    Auto-check: warnings
  • Build dependency chains, rebuild sequences, profiling with MCP, and Analysis MCP server setup for Verter

    112 GitHub stars~4.3k tokensUpdated today
    Auto-check passed
  • Compiler Codegen

    pikax/verter

    Rust compiler pipeline, template codegen (VDOM/IDE), CodeTransform, cached directives, strict slots, IDE error recovery, style preprocessing, CompileTarget, compiler authority/policy/demand/admission

    112 GitHub stars~21k tokensUpdated today
    Auto-check passed
  • CTO/manager-of-managers methodology for autonomous multi-train plans where the user says "you are the MoM/CTO", "orchestrate the whole plan", "drive the migration end-to-end", "manager-of-managers"…

    112 GitHub stars~3.5k tokensUpdated today
    Auto-check passed
  • Signature Kernel

    pikax/verter

    Verter semantic signature kernel — signature records/descriptors, epoch-safe interned storage and retirement, request-pinned borrowed reads, positional matching, call substitution, ordered…

    112 GitHub stars~4.4k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Rust Performance

What does Rust Performance do?

Rust performance optimization patterns: batch operations, allocation hierarchy, object pooling, CodeTransform API for vertercompiler. Rust Performance is an agent skill from pikax/verter.

When should I use Rust Performance?

Rust Performance fits situations like: tasks that involve Performance optimization.

How do I install Rust Performance in Claude Code?

Run `npx skills add pikax/verter --skill rust-performance -a claude-code`. Or copy the skill folder (.claude/skills/rust-performance in pikax/verter) into .claude/skills/rust-performance in your project. Claude Code loads it when a task matches its description.

How do I install Rust Performance in Codex?

Run `npx skills add pikax/verter --skill rust-performance -a codex`. Or copy the skill folder (.claude/skills/rust-performance in pikax/verter) into .agents/skills/rust-performance in your project. Codex loads it when a task matches its description.

Can I use Rust Performance in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pikax/verter --skill rust-performance -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rust-performance, .gemini/skills/rust-performance, .github/skills/rust-performance and .opencode/skills/rust-performance in your project.

What does Rust Performance need to run?

Going by SKILL.md and its folder, Rust Performance needs the command-line tools its instructions call (pnpm).

Does Rust Performance access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Rust Performance safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Rust Performance use?

Rust Performance is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rust Performance use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Rust Performance?

Skills that share tags, products or a category with Rust Performance: Samply (vortex-data/vortex, 3.2k stars), Investigate User Bug (cristicretu/diri, 424 stars), Cpp (crazyguitar/cppcheatsheet, 290 stars) and Rust Profiling (diodeme/Gold-Band, 143 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rust Performance?

pikax (a GitHub user) maintains it in pikax/verter, which has 112 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on October 7, 2026.

Source: pikax/verter on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.