AI-Powered Performance Analysis for ColdFusion

Analyze heap dumps, thread dumps, and GC logs with AI to identify performance issues

Analyzing heap dumps, thread dumps, and GC logs is complex and time-consuming. AI can analyze gigabytes of performance data in seconds, identifying memory leaks, thread deadlocks, inefficient queries, and JVM tuning opportunities—all while keeping your production data secure with local AI models.

Local AI Setup for Performance Analysis

Performance data often contains business-sensitive patterns. Use local AI to keep data private.

Recommended Models

DeepSeek Coder (Best for Code Analysis)

# Install via Ollama
ollama pull deepseek-coder:33b

# Use for analyzing slow code
ollama run deepseek-coder:33b

# Good for: Code optimization, query rewriting

Mixtral (Best for Log Analysis)

# Install via Ollama
ollama pull mixtral:8x7b

# Use for analyzing GC logs, thread dumps
ollama run mixtral:8x7b

# Good for: Pattern recognition in large text files

Automated Performance Analysis Script

#!/bin/bash
# perf-analyze.sh - Automated performance analysis

# Capture current state
echo "Capturing performance data..."
jstack $(pgrep -f coldfusion) > data/thread-dump-$(date +%Y%m%d-%H%M%S).txt
curl -s http://localhost:8500/metrics > data/cf-metrics-$(date +%Y%m%d-%H%M%S).json

# Analyze latest thread dump
LATEST_THREADDUMP=$(ls -t data/thread-dump-*.txt | head -1)

cat <<EOF | ollama run mixtral:8x7b > reports/thread-analysis.txt
Analyze this ColdFusion thread dump for:
- Deadlocks
- Thread pool exhaustion
- Excessive BLOCKED threads
- Thread leaks
- Recommended thread pool sizing

Thread Dump:
$(cat $LATEST_THREADDUMP)
EOF

# Analyze GC logs if present
if [ -f gc.log ]; then
  tail -n 5000 gc.log | ollama run mixtral:8x7b \
    "Analyze these GC logs and recommend JVM tuning" \
    > reports/gc-analysis.txt
fi

echo "Analysis complete. Check reports/ directory."

Why AI for Performance Analysis?

Traditional performance analysis requires expert knowledge of JVM internals, ColdFusion architecture, and manual correlation of multiple data sources. AI accelerates performance optimization by:

  • Pattern Recognition: Identify subtle performance patterns across massive datasets
  • Root Cause Analysis: Correlate symptoms across heap dumps, thread dumps, and logs
  • Instant Expertise: Access JVM tuning knowledge without years of experience
  • Automated Recommendations: Get specific JVM flags and code changes
  • Time Savings: Hours of analysis reduced to minutes
  • Education: Learn why performance issues occur and how to prevent them

Performance Issues AI Can Diagnose

1. Memory Leaks

AI analyzes heap dumps to identify memory leaks and their source:

Prompt: "Analyze this Eclipse MAT heap dump summary for memory leaks.

Heap Dump Summary:
- Total heap: 8GB
- Used heap: 7.2GB (90%)
- Objects: 45 million
- Top memory consumers:
  1. java.util.HashMap - 2.1GB (28 million instances)
  2. java.lang.String - 1.8GB (15 million instances)
  3. coldfusion.runtime.TemplateCache - 890MB
  4. com.myapp.SessionData - 650MB (125k instances)

Retained heap by class:
- SessionData: 2.3GB total retained
- HashMap entries referencing SessionData: 1.9GB

Provide:
- Root cause of the memory leak
- Which application code is causing it
- Recommended fix
- JVM tuning to mitigate
- Monitoring to detect early"

2. Thread Deadlocks

AI identifies deadlocks and thread contention in thread dumps:

Prompt: "Analyze this thread dump for deadlocks and performance issues.

Thread Dump Summary:
Total threads: 450
- RUNNABLE: 25
- WAITING: 380
- TIMED_WAITING: 35
- BLOCKED: 10

Thread "http-nio-8080-exec-245" BLOCKED on lock owned by thread "http-nio-8080-exec-189"
waiting to lock <0x000000070e4a5678> (a com.myapp.CacheLock)

Thread "http-nio-8080-exec-189" BLOCKED on lock owned by thread "http-nio-8080-exec-245"
waiting to lock <0x000000070e4a5abc> (a com.myapp.DatabaseLock)

Identify:
- Deadlock cause and involved threads
- Application code causing deadlock
- Other performance bottlenecks
- Thread pool sizing issues
- Recommended fixes"

3. GC Performance Issues

Prompt: "Analyze these GC logs for performance problems.

GC Log Summary (last hour):
- Full GC count: 47
- Full GC average time: 3.2 seconds
- Full GC max time: 8.7 seconds
- Total GC time: 428 seconds (11.9% of hour)
- Heap after Full GC: 6.8GB / 8GB (85% full)

Young Gen GCs:
- Count: 892
- Average time: 45ms
- Promotion rate: 450MB/min

Identify:
- Why Full GCs are frequent
- If heap size is appropriate
- Recommended GC algorithm
- JVM flags to improve performance
- Application-level fixes needed"

4. Slow Query Analysis

Prompt: "Analyze this slow query and execution plan.

Query (execution time: 18.5 seconds):
SELECT u.*, o.*, p.*
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
LEFT JOIN products p ON o.product_id = p.id
WHERE u.created_date > '2024-01-01'
AND o.status IN ('pending', 'processing')
ORDER BY o.created_date DESC

Execution Plan:
1. Full table scan on users (8.2M rows)
2. Nested loop join with orders (45M rows)
3. Nested loop join with products (120k rows)
4. Filesort for ORDER BY

Table stats:
- users: 8.2M rows, indexes on id, email
- orders: 45M rows, indexes on id, user_id
- products: 120k rows, indexes on id

Provide:
- Bottleneck analysis
- Missing indexes
- Query rewrite suggestions
- Estimated improvement
- Testing approach"

AI Performance Analysis Workflow

Phase 1: Data Collection

Step 1: Capture Performance Data

Collect diagnostic data when performance degrades:

# Capture thread dump
jstack <CF_PID> > thread-dump.txt

# Capture heap dump
jmap -dump:live,format=b,file=heap-$(date +%Y%m%d-%H%M%S).hprof <CF_PID>

# Enable GC logging (add to jvm.config)
-Xlog:gc*:file=gc.log:time,uptime:filecount=5,filesize=20m

# Export CF performance metrics
curl http://localhost:8500/metrics > cf-metrics.json

Step 2: Sanitize Data for AI Analysis

Remove sensitive data before sending to AI:

# For thread dumps: redact stack traces with business logic
sed 's/com\.mycompany\.[^.]*/com.mycompany.REDACTED/g' thread-dump.txt

# For heap dumps: use summary only (not raw dump)
# Use Eclipse MAT to generate summary report
# Share only class names and counts, not object contents

# For GC logs: safe to share as-is (no business data)

# For queries: replace literal values with placeholders
sed "s/'[^']*'/'REDACTED'/g" slow-queries.log

Phase 2: AI-Powered Analysis

Heap Dump Analysis with AI

Prompt: "Analyze this heap dump summary from Eclipse MAT.

Leak Suspects:
Problem Suspect 1:
38% of heap (3.1GB) is retained by:
com.myapp.cache.SessionCache @ 0x7f4e2a1c3d80
  ├─ java.util.concurrent.ConcurrentHashMap @ 0x7f4e2a1c3da0
  │   └─ 125,847 x com.myapp.model.UserSession
  └─ Accumulator: Growing at ~50MB/hour

Path to GC Root:
Thread "session-cleanup" → SessionCache → ConcurrentHashMap

Provide:
1. Root cause explanation
2. Why sessions aren't being cleaned up
3. Application code location likely responsible
4. Recommended fix with code example
5. JVM settings to help mitigate
6. How to verify the fix worked"

JVM Tuning Recommendations

Prompt: "Recommend JVM tuning based on these symptoms:

Environment:
- ColdFusion 2025 on Linux
- Current heap: -Xms8g -Xmx8g
- GC: G1GC (default settings)
- Hardware: 32GB RAM, 16 CPU cores

Symptoms:
- Frequent Full GCs (every 5-10 minutes)
- Full GC pause times: 2-8 seconds
- Heap stays at 85-90% after Full GC
- Young gen promotion rate: 500MB/min
- Application serves 1000 req/min

Provide:
1. Recommended heap size
2. G1GC tuning flags
3. Other JVM flags to improve performance
4. Expected improvement
5. Monitoring to verify improvements
6. When to consider different GC algorithm"

Phase 3: Code-Level Optimization

Identify Performance Hotspots

Prompt: "Analyze this ColdFusion code for performance issues:

<cffunction name="processOrders">
  <cfquery name="getAllOrders" datasource="#dsn#">
    SELECT * FROM orders WHERE processed = 0
  </cfquery>

  <cfloop query="getAllOrders">
    <cfquery name="getOrderDetails" datasource="#dsn#">
      SELECT * FROM order_items WHERE order_id = #getAllOrders.id#
    </cfquery>

    <cfquery name="getCustomer" datasource="#dsn#">
      SELECT * FROM customers WHERE id = #getAllOrders.customer_id#
    </cfquery>

    <cfset processOrder(getAllOrders, getOrderDetails, getCustomer)>
  </cfloop>
</cffunction>

Execution stats:
- Called 50 times per minute
- Average execution time: 2.3 seconds
- Database queries: 300 per execution

Provide:
1. Performance bottlenecks
2. N+1 query problem analysis
3. Optimized code version
4. Expected performance improvement
5. Caching strategy if applicable"

Database Query Optimization

Prompt: "Optimize this query that takes 12 seconds:

SELECT
  c.id, c.name, c.email,
  COUNT(o.id) as order_count,
  SUM(o.total) as lifetime_value,
  MAX(o.created_date) as last_order_date,
  (SELECT COUNT(*) FROM support_tickets WHERE customer_id = c.id) as ticket_count
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id
WHERE c.status = 'active'
GROUP BY c.id
ORDER BY lifetime_value DESC
LIMIT 100

Execution plan shows:
- Full table scan on customers (2M rows)
- Nested loop for orders join (8M rows)
- Correlated subquery executed 2M times
- Filesort on 2M rows

Provide:
1. Query rewrite to eliminate subquery
2. Required indexes
3. Alternative approaches (denormalization, caching)
4. Estimated execution time after optimization
5. Testing methodology"

Specific Performance Scenarios

High Memory Usage Investigation

Prompt Template:
"Investigate high memory usage in ColdFusion application.

Symptoms:
- Heap usage: [X%]
- Frequency of Full GCs: [every X minutes]
- Full GC pause times: [X seconds]
- Application type: [web app / batch processing / API]
- Traffic pattern: [steady / spiky / growing]

Heap dump summary:
[paste Eclipse MAT summary]

GC log analysis:
[paste GC statistics]

Provide:
1. Is this a memory leak or undersized heap?
2. If leak, what's the source?
3. If undersized, what size is needed?
4. Application-level fixes required
5. JVM tuning recommendations
6. Monitoring to track progress"

Slow Application Response

Prompt Template:
"Diagnose slow ColdFusion application performance.

Metrics:
- Average response time: [X ms]
- 95th percentile: [X ms]
- 99th percentile: [X ms]
- Requests per second: [X]
- Active threads: [X / Y total]

Thread dump shows:
- [X] threads WAITING on database
- [Y] threads BLOCKED on locks
- [Z] threads RUNNABLE doing work

Slow requests:
[paste FusionReactor slow request log or CF debug output]

Diagnose:
1. Primary bottleneck (database / code / lock contention)
2. Specific code locations causing slowness
3. Quick wins for immediate improvement
4. Long-term architectural changes needed
5. Monitoring to track improvements"

Database Connection Pool Exhaustion

Prompt: "Analyze database connection pool issues.

Datasource config:
- Max connections: 50
- Timeout: 30 seconds

Symptoms:
- "Connection pool exhausted" errors
- Thread dump shows 45 threads WAITING on database
- Some queries take 10+ seconds
- Error rate spikes during peak traffic

Thread dump analysis:
- Threads waiting for connection: 45
- Threads with active query: 48
- Average query time from logs: 2.3s
- Slowest queries: 15-30s

Diagnose:
1. Is pool too small or queries too slow?
2. Are there query optimization opportunities?
3. Recommended pool size
4. Query optimization priorities
5. Connection leak detection strategy"

Advanced AI Performance Techniques

Comparative Analysis

Use AI to compare before/after performance data:

Prompt: "Compare these two performance profiles.

Before optimization:
- Avg response time: 850ms
- GC time: 12% of runtime
- Database queries: 45 per request
- Memory usage: 85% heap

After optimization:
- Avg response time: 320ms
- GC time: 3% of runtime
- Database queries: 8 per request
- Memory usage: 60% heap

Analyze:
1. Which optimizations had most impact?
2. Are there remaining bottlenecks?
3. Is performance gain sustainable?
4. Recommendations for further improvement
5. Monitoring to ensure gains persist"

Capacity Planning

Prompt: "Project capacity needs based on current metrics.

Current state:
- Traffic: 500 requests/min
- Response time: 450ms average
- CPU usage: 60%
- Memory usage: 70%
- Server specs: 16 cores, 32GB RAM

Growth plan:
- Traffic will grow to 2000 requests/min in 6 months

Provide:
1. Can current hardware handle 4x traffic?
2. Recommended hardware for target traffic
3. Application optimizations needed
4. Horizontal vs vertical scaling recommendation
5. Load testing strategy to verify capacity"

AI Performance Analysis Checklist

  • Local AI model installed for performance analysis
  • Performance data collection scripts configured
  • Baseline performance metrics captured
  • Heap dump analysis completed
  • Thread dump analysis completed
  • GC log analysis completed
  • Slow query analysis completed
  • AI recommendations documented
  • Optimization plan created
  • Testing strategy for validating improvements
  • Monitoring configured to track progress
  • Team trained on AI performance tools

Gotchas

  • AI doesn't know your business logic: May suggest optimizations that break functionality
  • Synthetic load testing: AI recommendations based on production load, not synthetic tests
  • Heap dump file size: Don't upload full heap dumps to AI - use summaries only
  • Context window limits: Large thread dumps may exceed AI context limits - summarize first
  • False correlation: AI may correlate unrelated events - verify causation
  • Over-optimization: AI may suggest micro-optimizations that add complexity for minimal gain
  • Hardware assumptions: AI may not know your hardware constraints

Related Resources

Need Performance Help?

Convective provides expert ColdFusion performance optimization services. We've tuned applications to handle 10x traffic with the same hardware. Learn more about our performance services.