Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

click-jvm-optimization点击 jvm 优化

Agent Skill

用于辅助 Java 项目开发、面向对象设计、Spring 生态、Maven 或 Gradle 依赖和后端工程实践。它适合让 Agent 分析类结构、设计接口、整理服务分层、生成测试或检查常见代码坏味道。使用时需要结合项目已有架构、包结构和依赖版本,不应只按通用教程改代码;涉及数据库、事务、并发或框架配置时,应先确认运行环境和回归测试范围。

总安装

272

周安装

11

GitHub Stars

6

下载量

85
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:click-jvm-optimization(点击 jvm 优化)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/click-jvm-optimization
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill click-jvm-optimization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill click-jvm-optimization

简介

click-jvm-optimization 用于辅助 Java 项目开发与优化,涵盖面向对象设计、Spring 生态集成及后端工程实践。

  • 它适合分析类结构、设计服务分层、生成测试用例或识别常见代码坏味道。
  • 使用时需结合项目现有架构和依赖版本,避免盲目套用通用模板。
  • 涉及数据库、事务或并发处理时,应先验证运行环境和回归测试范围。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Cliff Click Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍​‌​​‌‌‌​‍​​​​‌‌‌​‍​​‌‌​‌​​‍​‌‌​​‌‌‌‍​​​​‌​​‌‍​‌‌​​​​‌⁠‍⁠

Overview

Cliff Click was the chief architect of the HotSpot Server Compiler (C2), which made Java competitive with C++ for server workloads. He invented the sea-of-nodes intermediate representation and pioneered optimization techniques used in most modern JIT compilers. His work proved that dynamic languages could be fast.

Core Philosophy

"Optimization is about proving things don't happen."
"The best optimization is the one that removes code entirely."
"A good IR makes optimizations fall out naturally."

Click believes that compiler optimization is fundamentally about building proofs—proving that code can be simplified, proving that operations can be reordered, proving that entire computations can be eliminated.

Design Principles

  1. Sea of Nodes IR: Data dependencies, not artificial instruction order.
  2. Speculative Optimization: Optimize for the common case, deoptimize when wrong.
  3. Type Speculation: Dynamic types can be optimized like static types.
  4. Escape Analysis: Prove objects don't escape, eliminate allocations.

When Building Compilers

Always

  • Design IR for the optimizations you want
  • Preserve information needed for later passes
  • Make deoptimization fast and correct
  • Profile to guide optimization decisions
  • Inline aggressively (with limits)
  • Prove properties rather than assuming them

Never

  • Lose information during lowering too early
  • Optimize without profiling data
  • Make deoptimization expensive
  • Assume optimization order doesn't matter
  • Skip escape analysis for object languages
  • Ignore memory aliasing

Prefer

  • Sea-of-nodes over linear IR for optimization
  • Speculative optimization with guards
  • Type feedback over static analysis alone
  • Global value numbering over local CSE
  • Loop transformations that enable vectorization
  • Incremental compilation over batch

Code Patterns

Sea of Nodes IR

// Traditional: Linear IR with explicit order
// t1 = load x
// t2 = load y
// t3 = add t1, t2
// store z, t3

// Sea of Nodes: Graph with data dependencies only
//
//    Start
//      |
//   Memory
//    /   \
// Load x  Load y
//    \   /
//     Add
//      |
//    Store z
//      |
//     End

class Node {
    int opcode;
    Node[] inputs;   // Data dependencies
    Node[] outputs;  // Uses of this node

    // No explicit "next" instruction
    // Order determined by dependencies
}

// Benefits:
// - Reordering is free (just valid orderings)
// - Dead code elimination is trivial (no outputs)
// - Common subexpression elimination natural
// - Control flow is just another dependency

Global Value Numbering

// Find redundant computations across entire method

class ValueNumbering {
    Map<NodeKey, Node> valueNumbers = new HashMap<>();

    Node idealize(Node n) {
        // Compute canonical form
        NodeKey key = canonicalize(n);

        // Already computed this value?
        Node existing = valueNumbers.get(key);
        if (existing != null) {
            return existing;  // Reuse existing computation
        }

        valueNumbers.put(key, n);
        return n;
    }

    NodeKey canonicalize(Node n) {
        // Commutative ops: sort operands
        if (isCommutative(n.opcode)) {
            sortInputs(n);
        }

        // Algebraic identities
        // x + 0 → x
        // x * 1 → x
        // x & x → x

        return new NodeKey(n.opcode, n.inputs);
    }
}

// In sea-of-nodes: value numbering IS the representation
// Each unique computation exists exactly once

Speculative Optimization with Guards

// Optimize for observed types, guard against others

void compileCallSite(CallSite site, ProfileData profile) {
    if (profile.isMonomorphic()) {
        // 95% of calls go to one method
        Class<?> observedType = profile.getObservedType();

        // Emit optimized code with guard
        emitTypeCheck(observedType);      // Guard
        emitDirectCall(observedType);     // Inline opportunity!
        emitDeoptimize();                 // Uncommon trap

    } else if (profile.isBimorphic()) {
        // Two types observed
        emitTypeSwitch(profile.getTypes());
        // Inline both paths

    } else {
        // Megamorphic: fall back to virtual dispatch
        emitVirtualCall();
    }
}

// Key insight: wrong guesses don't crash
// They just deoptimize and continue in interpreter

Escape Analysis

// Prove object doesn't escape → eliminate allocation

class EscapeAnalysis {
    boolean canEliminate(AllocationNode alloc) {
        // Track all uses of the allocation
        Set<Node> uses = alloc.getTransitiveUses();

        for (Node use : uses) {
            if (escapes(alloc, use)) {
                return false;
            }
        }

        return true;  // Safe to scalar replace
    }

    boolean escapes(AllocationNode alloc, Node use) {
        // Escapes if:
        // - Stored to heap (another object's field)
        // - Passed to unknown method
        // - Returned from method
        // - Stored to static field
        // - Used in synchronization

        if (use instanceof StoreField) {
            StoreField sf = (StoreField) use;
            return sf.getObject() != alloc;  // Storing TO another object
        }

        if (use instanceof Call) {
            Call call = (Call) use;
            return !isInlinedCall(call);
        }

        // ... other escape conditions
        return false;
    }
}

// Scalar replacement: object fields become local variables
// Point p = new Point(x, y);
// return p.x + p.y;
//
// Becomes:
// int p_x = x;
// int p_y = y;
// return p_x + p_y;
//
// No allocation!

Loop Optimizations

// Loop transformations for performance

class LoopOptimizations {

    void optimizeLoop(LoopNode loop) {
        // 1. Loop invariant code motion
        // Move computations out of loop if they don't change
        for (Node n : loop.getBody()) {
            if (isLoopInvariant(n, loop)) {
                moveBeforeLoop(n, loop);
            }
        }

        // 2. Induction variable analysis
        // Recognize i++, i += stride patterns
        InductionVar iv = findInductionVariable(loop);

        // 3. Range check elimination
        // array[i] where 0 <= i < array.length
        // Hoist bounds check outside loop
        if (canEliminateRangeCheck(loop, iv)) {
            hoistRangeCheck(loop, iv);
        }

        // 4. Loop unrolling
        // Reduce loop overhead, enable more optimization
        if (shouldUnroll(loop)) {
            unroll(loop, UNROLL_FACTOR);
        }

        // 5. Vectorization
        // Process multiple iterations with SIMD
        if (canVectorize(loop)) {
            vectorize(loop);
        }
    }
}

Deoptimization Infrastructure

// Fast path to slow path transition

class Deoptimization {
    // Deopt point: return to interpreter with correct state

    static class DeoptInfo {
        int bci;                    // Bytecode index
        Object[] locals;            // Local variable values
        Object[] stack;             // Stack values
        Object[] monitors;          // Held locks
    }

    void deoptimize(DeoptInfo info) {
        // 1. Rebuild interpreter frame
        InterpreterFrame frame = new InterpreterFrame();
        frame.setBCI(info.bci);
        frame.setLocals(info.locals);
        frame.setStack(info.stack);

        // 2. Re-acquire monitors
        for (Object monitor : info.monitors) {
            monitorEnter(monitor);
        }

        // 3. Resume in interpreter
        // (Much slower, but correct)
        interpreter.execute(frame);

        // 4. Maybe recompile with new profile info
        // The failed speculation taught us something
    }
}

// Key: compiled code can ALWAYS return to interpreter
// This makes speculative optimization safe

Type Feedback System

// Collect runtime type information

class TypeProfile {
    // At each call site, track observed receiver types
    TypeProfileEntry[] receivers = new TypeProfileEntry[2];
    int count;

    void recordType(Class<?> type) {
        for (int i = 0; i < count; i++) {
            if (receivers[i].type == type) {
                receivers[i].count++;
                return;
            }
        }

        if (count < receivers.length) {
            receivers[count++] = new TypeProfileEntry(type, 1);
        } else {
            // Too many types: mark megamorphic
            morphism = MEGAMORPHIC;
        }
    }

    OptimizationHint getHint() {
        if (count == 1 && receivers[0].count > THRESHOLD) {
            return new Monomorphic(receivers[0].type);
        }
        if (count == 2) {
            return new Bimorphic(receivers[0].type, receivers[1].type);
        }
        return MEGAMORPHIC;
    }
}

// Profile-guided optimization:
// 1. Run in interpreter, collect profiles
// 2. Compile hot methods with profile data
// 3. Speculate based on observed types
// 4. Deoptimize if speculation wrong
// 5. Recompile with updated profile

Register Allocation

// Graph coloring register allocation

class RegisterAllocator {
    void allocate(Graph graph) {
        // Build interference graph
        // Two values interfere if both live at same point
        InterferenceGraph ig = buildInterferenceGraph(graph);

        // Color graph with K colors (K = register count)
        // Adjacent nodes get different colors
        Map<Node, Integer> coloring = colorGraph(ig);

        // Handle spills
        // If can't color, spill some values to stack
        while (coloring == null) {
            Node toSpill = selectSpillCandidate(ig);
            insertSpillCode(toSpill);
            ig = rebuild(ig, toSpill);
            coloring = colorGraph(ig);
        }

        // Assign physical registers
        for (Map.Entry<Node, Integer> e : coloring.entrySet()) {
            e.getKey().setRegister(physicalRegister(e.getValue()));
        }
    }
}

JIT Compilation Philosophy

Tiered Compilation Strategy
══════════════════════════════════════════════════════════════

Tier    Compiler    Optimization    When Used
────────────────────────────────────────────────────────────
0       Interpreter None           First execution
1       C1 (Client) Light          Moderate hotness
2       C2 (Server) Aggressive     Very hot methods

Compilation triggers:
- Method entry count threshold
- Loop back-edge count threshold
- On-stack replacement for hot loops

Key insight: Most code is cold
            Compile only what matters
            Quick startup, peak performance eventually

Mental Model

Click approaches compiler design by asking:

  1. What can I prove? Optimizations are proofs
  2. What's the common case? Speculate on it
  3. What information do I need? Preserve it in the IR
  4. What can be eliminated? The fastest code is no code
  5. How do I recover when wrong? Deoptimization must work

Signature Click Moves

  • Sea-of-nodes IR: Dependencies, not artificial order
  • Speculative optimization: Bet on the common case
  • Escape analysis: Eliminate allocations entirely
  • Global value numbering: One computation per value
  • Profile-guided optimization: Runtime feedback guides compilation
  • Tiered compilation: Quick startup, peak performance later
  • Deoptimization: Safe return to interpreter
  • Loop optimizations: Range checks, unrolling, vectorization

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

31.41%
按下载量换算27

Claude

30.22%
按下载量换算26

Cursor

19.82%
按下载量换算17

Gemini CLI

9.44%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills