You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .codex/skills/high-performance-java/SKILL.md
+54-9Lines changed: 54 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,33 @@
1
1
---
2
2
name: high-performance-java
3
-
description: Use when writing, reviewing, or reshaping HotSpot Java where throughput, latency, allocation rate, zero-copy, lazy evaluation, non-materialization, intrinsics, SuperWord auto-vectorization, or C2 assembly matter. Bias toward specialized hot-path code, then ground claims in benchmarks and JIT evidence.
3
+
description: Use when writing, reviewing, or reshaping HotSpot Java where algorithmic complexity, data-structure choice, throughput, latency, allocation rate, zero-copy, lazy evaluation, non-materialization, primitive collections, performance libraries, intrinsics, SuperWord auto-vectorization, or C2 assembly matter. Also use for advanced algorithmic problem solving in Java, including dynamic programming, graph/range techniques, and cache-aware code shape. Bias toward asymptotic wins first, then specialized hot-path code, then benchmark and JIT evidence.
4
4
---
5
5
6
6
# High-Performance Java
7
7
8
-
Use this skill for Java hot paths. Default bias: fewer allocations, fewer copies, less polymorphism, narrower code shape, stronger evidence.
8
+
Use this skill for Java hot paths and algorithm-heavy Java. Default bias: asymptotic win first, then fewer allocations, fewer copies, less polymorphism, narrower code shape, stronger evidence.
- Do not micro-optimize a fundamentally wrong algorithm.
36
42
- Do not defend a perf change with style arguments alone.
37
43
- Do not claim “faster” without a measurement path.
38
44
- Do not claim “JIT will optimize this” without checking inlining / compilation evidence.
45
+
- Do not add a specialized library until you know what property it buys: fewer allocations, fewer copies, lower contention, off-heap layout, better primitive support, or a stronger algorithm.
39
46
- Do not keep elegant-but-generic stream pipelines in verified hot loops.
40
47
- Do not pay interface / visitor / wrapper overhead inside the hottest loop unless evidence shows it disappears.
48
+
- Do not default to boxed `Map<K, V>` / `Set<T>` / `List<T>` shapes when primitive collections or flat arrays better fit the dominant path.
41
49
42
50
## Design checklist
43
51
44
52
Ask these first:
53
+
- What are `N`, `Q`, the update/query ratio, and the memory budget?
54
+
- Is the main problem asymptotic complexity, cache locality, allocation pressure, branchiness, contention, or I/O?
55
+
- What operation dominates: membership, counting, top-k, range query, join, shortest path, DP transition, parsing, encoding?
56
+
- Can the key/value/state space stay primitive or bit-packed?
57
+
- Can the workload become offline, batched, sorted, prefix-based, or compressed?
45
58
- What allocates on the steady-state path?
46
59
- What copies bytes, chars, arrays, or collections?
47
60
- What materializes intermediate state that could stay streamed or cursor-based?
@@ -51,6 +64,18 @@ Ask these first:
51
64
52
65
## Workflow
53
66
67
+
### 0) Pick the algorithmic shape
68
+
69
+
- Estimate the real workload: input size, query count, mutation pattern, latency target, and memory ceiling.
70
+
- Choose the algorithm and data structure before tuning loop syntax.
71
+
- Favor contiguous, cache-friendly, primitive-heavy representations when semantics allow.
72
+
- For dynamic programming, define state, transition cost, base case, iteration order, and whether state compression is possible.
73
+
- For graph/range/string problems, look for offline transforms, prefix structures, monotonic structures, or specialized search before hand-tuning.
74
+
75
+
Read these only when relevant:
76
+
-[references/algorithms-data-structures.md](references/algorithms-data-structures.md) for algorithm and data-structure selection.
77
+
-[references/advanced-coding-techniques.md](references/advanced-coding-techniques.md) for dynamic programming and advanced problem-solving patterns.
78
+
54
79
### 1) Shape the code for HotSpot
55
80
56
81
- Split hot and cold paths.
@@ -84,10 +109,20 @@ When a benchmark moves, inspect what HotSpot actually did:
84
109
85
110
Use sibling skill [hotspot-jit-forensics](../hotspot-jit-forensics/SKILL.md) for method-scoped C2 evidence. Use `async-profiler-java-macos` when wall/cpu/alloc evidence is needed on macOS.
86
111
87
-
### 4) Report honestly
112
+
### 4) Use libraries intentionally
113
+
114
+
- Prefer the JDK first when it is close enough and operationally simpler.
115
+
- Reach for specialized libraries when they remove boxing, copies, parser overhead, contention, or off-heap indirection the JDK cannot.
116
+
- Check dependency health before adding a new library.
117
+
- Benchmark the library choice against the simplest credible in-repo baseline.
default_prompt: "Use $high-performance-java to write or review a Java hot path with benchmark and HotSpot evidence."
3
+
short_description: "Hot-path Java plus algorithm/perf-library guidance"
4
+
default_prompt: "Use $high-performance-java to choose the right algorithm, data structure, library, and HotSpot-friendly code shape for a high-performance Java task."
Use this reference when the problem needs more than basic loops and collections: dynamic programming, advanced search, state compression, offline transforms, or optimization patterns that materially change runtime.
4
+
5
+
## Dynamic programming checklist
6
+
7
+
Before writing code, define:
8
+
- state: the minimum information needed to continue
9
+
- transition: how one state moves to the next
10
+
- base case: the smallest solved states
11
+
- order: top-down memoization or bottom-up tabulation
0 commit comments