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: docs/getting-started/java-installation.mdx
+13-43Lines changed: 13 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,9 @@ keywords:
15
15
]
16
16
---
17
17
18
-
Codeflash supports Java projects using Maven or Gradle build systems. It uses a two-stage tracing approach to capture method arguments and profiling data from running Java programs, then optimizes the hottest functions.
18
+
Codeflash supports optimizing Java projects using Maven or Gradle build systems. It works in two main ways:
19
+
1. Codeflash can optimize new java code written in a Pull Request through Github Actions.
20
+
2. Codeflash can optimize real workloads end to end. It uses a two-stage tracing approach to capture method arguments and profiling data from running Java program, then optimizes the hottest functions with that data.
19
21
20
22
### Prerequisites
21
23
@@ -32,16 +34,16 @@ Good to have (optional):
32
34
<Steps>
33
35
<Steptitle="Install Codeflash CLI">
34
36
35
-
Codeflash CLI is a Python tool. Install it with pip:
37
+
Codeflash uses Python to run its CLI. You can use uv as a package manager and installer for Python programs.
38
+
To install uv, run the following or [see these instructions](https://docs.astral.sh/uv/getting-started/installation/)
36
39
37
-
```bash
38
-
pip install codeflash
39
-
```
40
-
41
-
Or with uv:
40
+
```bash
41
+
curl -LsSf https://astral.sh/uv/install.sh | sh
42
+
```
43
+
Then install Codeflash as a uv tool.
42
44
43
45
```bash
44
-
uv pip install codeflash
46
+
uv tool install codeflash
45
47
```
46
48
47
49
</Step>
@@ -56,30 +58,12 @@ codeflash init
56
58
This will:
57
59
- Detect your build tool (Maven/Gradle)
58
60
- Find your source and test directories
59
-
- Create a `codeflash.toml` configuration file
60
-
61
-
</Step>
62
-
<Steptitle="Verify setup">
63
-
64
-
Check that the configuration looks correct:
65
-
66
-
```bash
67
-
cat codeflash.toml
68
-
```
69
-
70
-
You should see something like:
71
-
72
-
```toml
73
-
[tool.codeflash]
74
-
module-root = "src/main/java"
75
-
tests-root = "src/test/java"
76
-
language = "java"
77
-
```
61
+
- Update your pom.xml or gradle settings with codeflash java library. The java library instruments your code and verifies correctness.
1. Profile your program using JFR (Java Flight Recorder)
96
80
2. Capture method arguments using a bytecode instrumentation agent
97
-
3. Generate JUnit replay tests from the captured data
81
+
3. Generate JUnit replay tests from the captured data to create a micro-benchmark.
98
82
4. Rank functions by performance impact
99
83
5. Optimize the most impactful functions
100
84
101
85
</Step>
102
86
</Steps>
103
87
104
-
## How it works
105
-
106
-
Codeflash uses a **two-stage tracing** approach for Java:
107
-
108
-
1.**Stage 1 — JFR Profiling**: Runs your program with Java Flight Recorder enabled to collect accurate method-level CPU profiling data. JFR has ~1% overhead and doesn't affect JIT compilation.
109
-
110
-
2.**Stage 2 — Argument Capture**: Runs your program again with a bytecode instrumentation agent that captures method arguments using Kryo serialization. Arguments are stored in an SQLite database.
111
-
112
-
The traced data is used to generate **JUnit replay tests** that exercise your functions with real-world inputs. Codeflash uses these tests alongside any existing unit tests to verify correctness and benchmark optimization candidates.
113
-
114
-
<Info>
115
-
Your program runs **twice** — once for profiling, once for argument capture. This separation ensures profiling data isn't distorted by serialization overhead.
0 commit comments