Skip to content

Moonsong-Labs/launch-benchmarks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moonbeam Node Start Benchmark

This repository contains benchmarks for measuring the startup time of a Moonbeam node using different JavaScript/TypeScript runtimes.

Latest Benchmark Results

Benchmark 1: native:bun
  Time (mean ± σ):      4.281 s ±  0.097 s    [User: 22.953 s, System: 0.491 s]
  Range (min … max):    4.133 s …  4.411 s    10 runs
 
Benchmark 2: native:node
  Time (mean ± σ):      5.153 s ±  0.066 s    [User: 24.277 s, System: 0.584 s]
  Range (min … max):    5.065 s …  5.294 s    10 runs
 
Benchmark 3: docker:node
  Time (mean ± σ):      5.332 s ±  0.104 s    [User: 2.419 s, System: 0.211 s]
  Range (min … max):    5.170 s …  5.517 s    10 runs
 
Benchmark 4: docker:bun
  Time (mean ± σ):      4.404 s ±  0.078 s    [User: 0.758 s, System: 0.116 s]
  Range (min … max):    4.286 s …  4.562 s    10 runs
 
  Time (mean ± σ):      6.151 s ±  0.104 s    [User: 2.744 s, System: 0.273 s]
  Range (min … max):    6.061 s …  6.407 s    10 runs
 
Summary
  native:bun ran
    1.03 ± 0.03 times faster than docker:bun
    1.20 ± 0.03 times faster than native:node
    1.25 ± 0.04 times faster than docker:node
    1.44 ± 0.04 times faster than testcontainers:node

Prerequisites

  1. Install Node.js v23
# Using nvm (recommended)
nvm install 23
nvm use 23
  1. Install Bun
curl -fsSL https://bun.sh/install | bash
  1. Install Hyperfine
# On Ubuntu/Debian
sudo apt-get install hyperfine

# On macOS
brew install hyperfine

Download Moonbeam Node

Download the latest Moonbeam binary from the official releases:

# Download latest binary (example for Linux)
wget https://github.com/moonbeam-foundation/moonbeam/releases/latest/download/moonbeam

# Make it executable
chmod +x moonbeam

Note

The moonbeam binary is already in .gitignore.

Setup

  1. Clone the repository
  2. Install dependencies:
bun install
  1. Compile the TypeScript:
bun run compile

Running Benchmarks

Individual Runs

To run the native benchmarks individually:

  1. Using Bun:
bun run native
  1. Using Node:
bun run native:node
  1. Using Docker with Bun:
bun run docker
  1. Using Docker with Node:
bun run docker:node
  1. Using Testcontainers with Node:
node --import tsx scripts/testcontainers.ts

Running Full Benchmark Suite

To run the complete benchmark comparison (includes all methods):

bun run bench

This will compare the following implementations:

  • Native implementation with Bun
  • Native implementation with Node
  • Docker implementation with Node
  • Docker implementation with Bun
  • Testcontainers implementation with Node

Docker Implementation

The project includes multiple Docker-based implementations:

  1. Direct Docker API: Uses the dockerode package to directly interact with the Docker daemon. This implementation can be found in scripts/docker.ts.

  2. Testcontainers: Uses the testcontainers package which provides a more testing-oriented approach to container management. This implementation can be found in scripts/testcontainers.ts.

Both implementations:

  • Pull and run the moonbeamfoundation/moonbeam container
  • Configure the necessary ports (9944)
  • Set up the required node arguments
  • Handle container lifecycle management

Prerequisites for Docker

  1. Install Docker on your system
  2. Make sure the Docker daemon is running
  3. Ensure your user has permissions to interact with Docker

Docker Commands

To manage Docker containers manually:

# Pull the Moonbeam image
docker pull moonbeamfoundation/moonbeam

# List running containers
docker ps

# Stop all running containers (if needed)
docker stop $(docker ps -q)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published