Documentation Index
Fetch the complete documentation index at: https://mintlify.com/meteor/meteor/llms.txt
Use this file to discover all available pages before exploring further.
Performance Profiling
Profiling helps identify performance bottlenecks in the Meteor build tool and application. This guide covers built-in profilers and profiling techniques from the Meteor source code.Built-in Profiler (METEOR_PROFILE)
Meteor includes a built-in profiler activated with theMETEOR_PROFILE environment variable.
Basic Usage
The value is interpreted as a threshold in milliseconds:Adjusting Threshold
Higher thresholds show only slower operations:Understanding Output
You’ll see reports like:Reading the Report
- Top-down listing - Hierarchical call structure
- Dotted lines - Entries with child entries
- Time - Total cumulative time of all calls
- Number in parentheses - Call count
- Other entries - Time not accounted for by instrumented children
Key Metrics
Important sections to watch:ProjectContext prepareProjectForBuild- Overall preparation time_initializeCatalog- Package catalog loading_resolveConstraints- Package version resolutionbundler.readJsImage- Loading compiled packagesImportScanner#_readFile- File scanning and reading
Inspector Profiling (METEOR_INSPECT)
Meteor includes advanced profiling using Node.js’sinspector module, generating .cpuprofile files.
Basic Usage
Specify which functions to profile:Profile Multiple Functions
Available Functions
Complete list forMETEOR_INSPECT:
bundler.bundlecompiler.compileBabel.compile_readProjectMetadatainitializeCatalog_downloadMissingPackages_saveChangeMetadata_realpathpackage-client
Configuration Options
Context identifier:./profiling
Sampling interval:
Complete Example
Viewing Profile Results
Chrome DevTools
- Open Chrome DevTools (F12)
- Go to “Performance” or “Profiler” tab
- Click “Load Profile”
- Select the
.cpuprofilefile
Discoveryjs cpupro
Open-source interactive CPU profile viewer: Online:- Visit https://discoveryjs.github.io/cpupro/
- Drag and drop your
.cpuprofilefile - Explore the interactive visualization
- Better handling of large profiles
- More flexible filtering
- Advanced search capabilities
- Multiple visualization modes
- Ability to compare profiles
Memory Optimization
Increasing Memory Limit
Inspector profiling consumes more memory:Memory Considerations
- Inspector profiling uses more memory than standard profiler
- Large profiles (>2GB) automatically truncated
- Consider
METEOR_INSPECT_MAX_SIZEto limit memory usage - Use standard profiler for quick analysis
When to Use Each Profiler
Use METEOR_PROFILE when:
- Quick performance check needed
- General analysis of build times
- Identifying obvious bottlenecks
- Low memory environment
- CI/CD performance monitoring
Use METEOR_INSPECT when:
- Deep analysis required
- Complex performance issues
- Specific bottleneck investigation
- Visual analysis needed
- Comparing multiple builds
Instrumenting Code
Add profiling annotations to your own code:Wrap Functions
Wrap Methods
Timed Blocks
Conditional Profiling
For packages loaded into the tool:Performance Considerations
Unreported Work
Not covered by standard reports:- App start-up time
- File watcher creation after rebuild
Caching Impact
Multiple cache layers affect timing:- Built packages and plugins
- Compiler plugin results (including old file versions)
- Linker output
- Server program (for client-only changes)
- Constraint solver results
- Initial build: Slowest (cold cache)
- First rebuild: Faster (warm cache)
- Second rebuild: Even faster (fully warm)
Release vs Checkout
Performance differences: Release Mode:- Faster startup
- Pre-built core packages
- Efficient constraint solving
- Recompiles core packages
- Large number of watched files
- Extra delay after rebuild
- Useful for tool development
Hardware and OS Impact
Disk Speed:- SSDs much faster than HDDs
- Impacts cache read/write times
- Mac/Linux: Fast file operations, symlinks, atomic renames
- Windows: Slower file operations, no symlinks, rename = copy
- Virus scanners can block/delay operations
Profiling Specific Areas
CSS Minification
CSS processing can take 500ms to several seconds:- CSS parsing time
- CSS generation time
- Source map generation
Constraint Solving
_resolveConstraintstime- Package database queries
- Logic solver invocations
File Watching
- File watcher creation
- File scanning operations
- WatchSet merging
Import Scanning
ImportScanner#_readFile- File reading operations
- SHA1 hashing
Comparing Performance
Before/After Optimization
-
Baseline profile:
- Apply optimization
-
New profile:
- Compare times for specific operations
Using meteor profile
Compare build performance:- Prepare project
- Build app
- Individual build steps
Debugging with node-inspector
For interactive debugging:Debugging Test Apps
Common Performance Issues
Large “other” Time
If you see:Profile calls to narrow down.
Source Map Generation
Noticeable time spent building source maps:- Consider more efficient use of
source-maplibrary - Look at Webpack’s optimizations
Linker Cache Writes
Large files taking seconds to write:- Watch
files.writeFileAtomicallycalls - May appear outside top level (async)
- Consider cleaning up old cache files
Package Server Updates
Slow “Updating package catalog…”:- Can take 5+ seconds
- Sometimes much longer
- Consider local package mirror
Best Practices
- Use appropriate profiler - METEOR_PROFILE for quick checks, METEOR_INSPECT for deep dives
- Set reasonable thresholds - Start with 100ms, adjust as needed
- Profile production builds - Different performance characteristics
- Clear caches first - For accurate cold-start measurements
- Profile multiple runs - Account for variability
- Watch for GC - Times can be inflated by garbage collection
- Consider hardware - SSD vs HDD, OS differences
- Instrument custom code - Add Profile calls to your plugins
- Compare apples to apples - Same cache state, same environment
- Document findings - Share results with team
Interpreting Results
Good Performance Indicators
- Most time in actual work (compile, bundle)
- Minimal “other” time
- Efficient cache usage
- Fast constraint solving
Red Flags
- Large “other” sections
- Repeated work (cache misses)
- Slow file operations
- Long constraint solving
- Excessive file scanning