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: .cursor/rules/161-java-profiling-detect.mdc
+68-41Lines changed: 68 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -27,35 +27,22 @@ The rule ensures consistent, repeatable profiling procedures while providing the
27
27
28
28
## ⚠️ CRITICAL INSTRUCTION FOR AI ASSISTANTS ⚠️
29
29
30
-
**WHEN USING THE PROFILING SCRIPT TEMPLATE:**
31
-
- **COPY THE BASH SCRIPT EXACTLY** from `java-profiling-script-template.md`
30
+
**WHEN USING THE PROFILING SCRIPT TEMPLATES:**
31
+
- **COPY THE BASH SCRIPT EXACTLY** from `java-profiling-script-template.md` or `java-profiling-script-run-app-template.md`
32
32
- **NO MODIFICATIONS, INTERPRETATIONS, OR ENHANCEMENTS** allowed
33
33
- **USE EVERY LINE VERBATIM** - do not change logic, structure, or features
34
34
- **DO NOT CREATE YOUR OWN VERSION** - use the provided template only
35
-
- The template script is complete, tested, and production-ready
35
+
- The template scripts are complete, tested, and production-ready
36
36
37
37
---
38
38
39
39
This rule provides comprehensive Java application profiling using async-profiler v4.0, including automatic OS detection, profiler download, and flamegraph generation with the latest features.
40
40
41
-
## Problem Identification
42
-
43
-
Before starting the profiling process, identify what specific performance problem you're trying to solve.
44
-
45
-
**Reference the profiling questions template:** [java-profiling-questions-template.md](mdc:.cursor/rules/templates/java-profiling-questions-template.md)
**IMPORTANT**: Use the exact bash script from the template without any modification or interpretation.
92
+
93
+
The application runner script is available at: [java-profiling-script-run-app-template.md](mdc:.cursor/rules/templates/java-profiling-script-run-app-template.md)
94
+
95
+
**CRITICAL INSTRUCTION FOR AI ASSISTANTS:**
96
+
- **COPY THE BASH SCRIPT EXACTLY** from the template file
97
+
- **DO NOT MODIFY, INTERPRET, OR ENHANCE** the script content
98
+
- **DO NOT ADD NEW FEATURES** or change the logic
99
+
- **USE THE SCRIPT VERBATIM** - every line, comment, and function exactly as provided
100
+
- The script is already complete and tested - no improvements needed
101
+
102
+
**Script Location:**
103
+
```
104
+
your-project/
105
+
└── run-with-profiler.sh # ← Run main application with the right JVM flags for profiling
106
+
```
107
+
108
+
**Setup Instructions:**
109
+
1. Copy the **EXACT** bash script content from `java-profiling-script-run-app-template.md`
110
+
2. Save it as `run-with-profiler.sh` in your project root
111
+
3. Make it executable: `chmod +x run-with-profiler.sh`
112
+
4. **NO MODIFICATIONS** to the script content are needed or allowed
113
+
114
+
**Purpose:**
115
+
- Configures JVM with profiling-friendly flags
116
+
- Ensures proper async-profiler compatibility
117
+
- Starts your application ready for profiling
118
+
97
119
**Usage:**
98
-
- Run `./profiler/scripts/java-profile.sh` for comprehensive interactive profiling
120
+
```bash
121
+
# Start your application with profiling-ready JVM settings
**IMPORTANT**: Use the exact bash script from the template without any modification or interpretation.
103
128
@@ -118,37 +143,39 @@ The complete interactive profiling script is available at: [java-profiling-scrip
118
143
```
119
144
120
145
**Setup Instructions:**
121
-
1. Copy the **EXACT** bash script content from `java-profiling-script-template.md`
122
-
2. Save it as `profiler/scripts/java-profile.sh`
123
-
3. Make it executable: `chmod +x profiler/scripts/java-profile.sh`
124
-
4. **NO MODIFICATIONS** to the script content are needed or allowed
146
+
1. Create the profiler directory structure: `mkdir -p profiler/scripts profiler/results`
147
+
2. Copy the **EXACT** bash script content from `java-profiling-script-template.md`
148
+
3. Save it as `profiler/scripts/java-profile.sh`
149
+
4. Make it executable: `chmod +x profiler/scripts/java-profile.sh`
150
+
5. **NO MODIFICATIONS** to the script content are needed or allowed
151
+
152
+
**Purpose:**
153
+
- Detects running Java processes automatically
154
+
- Downloads and configures async-profiler v4.0
155
+
- Provides interactive menu for different profiling scenarios
156
+
- Generates flamegraphs and analysis reports
125
157
126
158
## Profiling Execution Workflow
127
159
128
-
After setting up the profiling scripts, follow this execution workflow to profile your Java application and store results in the profiler/results directory:
160
+
After setting up both scripts, follow this execution workflow:
129
161
130
-
### Step 1: Create and Make Script Executable
162
+
### Step 1: Start Your Application with Profiling Support
131
163
132
-
**CRITICAL**: Use the exact script from the template without any changes:
164
+
First, start your application using the profiling-ready runner:
133
165
134
166
```bash
135
-
# Create the profiler directory structure
136
-
mkdir -p profiler/scripts
137
-
mkdir -p profiler/results
138
-
139
-
# Copy the EXACT bash script from java-profiling-script-template.md
140
-
# Save it as profiler/scripts/java-profile.sh
141
-
# DO NOT MODIFY THE SCRIPT CONTENT - USE IT EXACTLY AS PROVIDED
142
-
143
-
# Make the script executable
144
-
chmod +x profiler/scripts/java-profile.sh
167
+
# Start your application with JVM flags optimized for profiling
168
+
./run-with-profiler.sh
145
169
```
146
170
147
-
**REMINDER**: The script in `java-profiling-script-template.md` is complete and should be copied verbatim. No interpretation, enhancement, or modification is required or allowed.
171
+
This script:
172
+
- Applies JVM flags that make profiling more accurate
173
+
- Ensures async-profiler can attach properly
174
+
- Starts your application in profiling-ready mode
148
175
149
-
### Step 2: Execute the Profiling Script
176
+
### Step 2: Run Interactive Profiling
150
177
151
-
Run the script from your project root directory:
178
+
In a separate terminal, execute the interactive profiling script:
152
179
153
180
```bash
154
181
# Execute the interactive profiling script
@@ -164,7 +191,7 @@ Run the script from your project root directory:
164
191
165
192
### Step 3: Problem-Specific Profiling Commands
166
193
167
-
Based on the problem you identified, execute these specific profiling commands:
194
+
Based on the problem you identified, the script will execute these specific profiling commands:
0 commit comments