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.
Build Performance Optimization
This guide covers performance considerations and optimization strategies for the Meteor build system.Profiling
Standard Profiler
The built-in profiler is activated with theMETEOR_PROFILE environment variable:
The value is interpreted as a threshold in ms, so the value 1 means to report on all calls that take more than 1ms.
Example Output
Inspector Profiling
For detailed performance analysis, use inspector profiling:Available Inspection Points
From PERFORMANCE.md:bundler.bundlecompiler.compileBabel.compile_readProjectMetadatainitializeCatalog_downloadMissingPackages_saveChangeMetadata_realpathpackage-client
Environment Variables
Viewing Results
Chrome DevTools:- Open Chrome DevTools
- Go to Performance or Profiler tab
- Click “Load Profile” and select the .cpuprofile file
- Visit https://discoveryjs.github.io/cpupro/
- Drag and drop your .cpuprofile file
- Use interactive visualization tools
Instrumenting Code
Add profiling annotations to tool code:Performance Considerations
Caching
The tool uses multiple cache layers: Package Caches:APP/.meteor/local/isopacks- Built packagesAPP/.meteor/local/bundler-cache- Bundler outputAPP/.meteor/local/plugin-cache- Plugin compilation~/.meteor/packages/- Downloaded packages
- Compiler plugin results (with source file versioning)
- Linker output
- Server program (for client-only changes)
- Constraint solver results
The tool saves work using various disk caches and in-memory caches… Compiler plugin results - and not just on the most recent version of a file! If you are testing rebuilds by toggling a character back and forth, you may hit cache.
Linker Cache
From compiler-plugin.js:Release vs. Checkout
From PERFORMANCE.md: Released Meteor:- Uses pre-built packages from
~/.meteor - Faster startup and rebuilds
- No core package compilation
- Recompiles core packages into
APP/.meteor/local/isopacks - Takes longer on first run (up to a couple minutes)
- More files to watch (slower rebuild preparation)
- Different constraint solver behavior
Checked-out Meteor recompiles core packages. When you run an app using checked-out Meteor, it will compile core packages into APP/.meteor/local/isopacks… This process can take a while — as much as a couple minutes — but it’s only done once per package per app.
Hardware Impact
From PERFORMANCE.md: Storage:Spinning disks are much slower than SSDs.Operating System:
- macOS/Linux: Fast symlinks, atomic renames, files can be deleted while open
- Windows: Rename is copy operation, path separator differences, virus scanners can delay operations
Windows doesn’t have these properties; for example, renaming a file is a copy operation.
Known Performance Issues
CSS Minification
From PERFORMANCE.md:Reparsing and merging the CSS for a typical app can take anywhere from 500ms to a couple seconds or more, depending on the amount of CSS.Potential improvements:
- Cache parsing results
- Only recalculate when CSS changes
- Use faster CSS library
Source Maps
The tool spends noticeable [time] building source maps… There’s some question of whether the source-map library is as efficient as it could be.
Linker Cache Files
From PERFORMANCE.md:
The “linker cache” on disk at APP/.meteor/local/bundler-cache/linker has some very large files that take a long time write, and they are apparently not cleaned up either.
Constraint Solving
Time spent reading from the packages database (a SQLite file) could be understood better and improved by batching queries, reading less data, or using SQLite better.
Package Server Updates
Talking to the package server to download new package metadata seems to take longer than it should; easily 5 seconds… and occasionally much longer.
Optimization Strategies
1. Minimize Dependencies
- Reduce total package count
- Avoid packages with large dependency graphs
- Use local packages when possible
2. Optimize File Watching
From PERFORMANCE.md:Different apps can strain different parts of the Meteor tool, such as: File watchers - lots of total files, e.g. thousands
- Keep
node_modulessmall - Use
.meteorignoreto exclude unnecessary files - Avoid deeply nested directory structures
3. Incremental Builds
- Make small, focused changes
- Leverage cached compiler results
- Use
--productiononly for final builds
4. Development Workflow
5. Clean Caches Selectively
6. Bundle Size Optimization
From bundler.js:7. Parallel Processing
From tools/README.md:Monitoring Build Performance
Time Tracking
Memory Management
Debugging Slow Builds
- Enable profiling:
METEOR_PROFILE=100 meteor run - Identify slow operations in output
- Use inspector profiling for detailed analysis
- Check cache directories for bloat
- Verify file watcher isn’t tracking too many files
Best Practices
- Use SSD storage for development
- Keep dependencies minimal and up-to-date
- Leverage caching - don’t clear caches unnecessarily
- Profile before optimizing - measure actual bottlenecks
- Use production mode only for final builds
- Monitor bundle size with production builds
- Instrument custom code for visibility
- Update Meteor regularly for performance improvements
Related Topics
- Isobuild - Build system architecture
- Bundler - Bundle generation
- Compiler Plugins - Plugin system