Profiler
Comprehensive guide to using the profiler for identifying and resolving server performance issues.
The Server profiler is an essential tool for identifying performance bottlenecks in your server. It provides detailed insights into script execution times, resource usage, and thread performance, helping you optimize your server's performance.
Regular profiling helps identify performance issues before they affect your players. Make it part of your development workflow.
Prerequisites
Before using the profiler:
- Ensure your client is up to date
- Use the latest server artifacts
- Have Google Chrome installed (required for viewing profiles)
- Keep your game/server running while viewing profiles
- Have sufficient permissions to access the console
Using the Profiler
Profiling can impact server performance. Use appropriate frame counts and enable only when needed.
Basic Commands
Command | Description |
---|---|
profiler record <frames> | Start recording a profile for specified number of frames |
profiler status | Check current recording status |
profiler view | View the current profile in Chrome (client-side only) |
profiler saveJSON <filename> | Save the profile to a JSON file |
Recording a Profile
-
Start Recording
-
Monitor Progress
Output example:
-
Save the Profile
Save profiles before and after optimizations to measure improvement and track changes over time.
Viewing Profiles
Client-Side Viewing
- Open the console (F8)
- Run
profiler view
- Chrome will automatically open with the profile
Server-Side Viewing
- Save the profile:
- Transfer the file to your local machine
- Open Chrome DevTools (Ctrl+Shift+I)
- Go to the Performance tab
- Right-click → Load profile
- Select your saved JSON file
Analyzing Profiles
Understanding the Interface
The profile view consists of several key components:
-
Timeline Overview
- Top: Recording timestamp
- Green line: FPS graph
- Yellow line: CPU time graph
- Red markers: Frame drops
-
Resource Breakdown
- Resource name
- Execution time (ms)
- File and line numbers
- Thread information
Identifying Issues
Server Hitches
- Look for sudden spikes in the CPU time graph
- Example: A spike from 5ms to 50ms indicates a potential hitch
- Common causes:
- Heavy database operations
- Unoptimized loops
- Resource conflicts
Frame Drops
- Check the FPS graph for significant dips
- Normal FPS should be stable (60 FPS)
- Dips below 30 FPS indicate performance issues
Resource Bottlenecks
- Hover over resource tick events to see:
Practical Examples
Example 1: Database Query Optimization
Example 2: Event Handler with Rate Limiting
Best Practices
Recording Strategy
- Start with 500 frames for initial analysis
- Increase to 1000+ frames for detailed profiling
- Record during peak server load
- Save multiple profiles for comparison
Analysis Tips
-
Focus Areas
- Sudden CPU time spikes
- Consistent frame drops
- Resource-intensive operations
- Thread conflicts
-
Common Patterns
- Regular spikes might indicate scheduled tasks
- Random spikes often point to event handling
- Consistent high CPU time suggests optimization needed
-
Optimization Priorities
- Address the highest CPU time operations first
- Focus on frequently called functions
- Check for resource conflicts
- Review event handling efficiency
Troubleshooting
-
Incomplete Profiles
- Increase frame count
- Check server stability
- Verify recording duration
-
Performance Impact
- Reduce frame count
- Profile during off-peak hours
- Use separate test server