mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
1.4 KiB
1.4 KiB
Hot Reload Files Stress Test
This is a stress test for Bun's hot reloading functionality, designed to test performance with a high number of interdependent files.
What It Does
- Generates 1000 interconnected TypeScript modules
- Each module imports 2 other modules
- Uses IPC (Inter-Process Communication) to detect reloads
- Performs 1,000 hot reloads and tracks memory usage
- Reports statistics about hot reload performance
Usage
./run-stress-test.sh
This will:
- Generate 1000 interconnected modules
- Run the stress test that performs 10,000 hot reloads
- Report complete performance statistics
How The Test Works
The test utilizes Node.js's child_process fork API for communication:
- The main process (stress-test.ts) creates a child process running Bun with hot reloading
- The modules communicate with the parent process via IPC when they're reloaded
- After detecting a successful reload, the parent modifies another file
- This continues for 1,000 iterations
- Memory usage is tracked throughout the process
Architecture
- generate.ts: Creates 1000 interconnected modules with IPC signaling
- stress-test.ts: Controls the test, forks Bun, and tracks metrics
- run-stress-test.sh: Script to run the entire test from scratch
Performance Metrics
The test reports:
- Total number of hot reloads completed
- Time taken to complete all reloads
- Average time per reload
- Initial and final RSS memory usage