Skip to content

Commit

Permalink
fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNineteen committed Jun 5, 2024
1 parent fd7bcab commit 4a84670
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 124 deletions.
76 changes: 41 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
zig fmt --check src/
zig fmt --check build.zig
build-unix:
test:
strategy:
matrix:
os: [ubuntu-latest]
Expand All @@ -42,41 +42,47 @@ jobs:
with:
version: 0.12.0

- name: build
run: zig build

- name: test
run: zig build test

- name: gossip
run: bash scripts/gossip_test.sh 120 # in seconds
benchmarks:
strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{matrix.os}}

steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: setup-zig
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.12.0

- name: benchmarks
run: zig build benchmark

# build-windows:
# runs-on: windows-latest
# defaults:
# run:
# shell: bash

# steps:
# - name: setup-git
# run: |
# git config --global core.autocrlf false
# git config --global core.eol lf

# - name: checkout
# uses: actions/checkout@v2
# with:
# submodules: recursive

# - name: setup-zig
# uses: goto-bus-stop/setup-zig@v1
# with:
# version: master

# - name: build
# run: |
# zig build -Dtarget=x86_64-windows --prefix tmp
# zig build

# - name: test
# run: zig build test
gossip:
strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{matrix.os}}

steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: setup-zig
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.12.0

- name: gossip
run: bash scripts/gossip_test.sh 120 # in seconds
6 changes: 4 additions & 2 deletions scripts/gossip_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
echo "Running gossip test for $1 seconds"

# build and run gossip
zig build
./zig-out/bin/sig gossip -e entrypoint.testnet.solana.com:8001 -e entrypoint2.testnet.solana.com:8001 &
zig build -Doptimize=ReleaseSafe && \
./zig-out/bin/sig gossip \
-e entrypoint.testnet.solana.com:8001 \
-e entrypoint2.testnet.solana.com:8001 &

# Get the process ID of the last background command
PID=$!
Expand Down
157 changes: 93 additions & 64 deletions src/accountsdb/db.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,6 @@ pub const BenchmarkAccountsDB = struct {
};

pub const args = [_]BenchArgs{
// test accounts in ram
BenchArgs{
.n_accounts = 100_000,
.slot_list_len = 1,
Expand All @@ -1258,81 +1257,111 @@ pub const BenchmarkAccountsDB = struct {
.name = "100k accounts (1_slot - ram index - ram accounts)",
},
BenchArgs{
.n_accounts = 10_000,
.slot_list_len = 10,
.accounts = .ram,
.index = .ram,
.name = "10k accounts (10_slots - ram index - ram accounts)",
},

// tests large number of accounts on disk
BenchArgs{
.n_accounts = 10_000,
.slot_list_len = 10,
.accounts = .disk,
.index = .ram,
.name = "10k accounts (10_slots - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 500_000,
.slot_list_len = 1,
.accounts = .disk,
.index = .ram,
.name = "500k accounts (1_slot - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 500_000,
.slot_list_len = 3,
.accounts = .disk,
.index = .ram,
.name = "500k accounts (3_slot - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 3_000_000,
.slot_list_len = 1,
.accounts = .disk,
.index = .ram,
.name = "3M accounts (1_slot - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 3_000_000,
.slot_list_len = 3,
.accounts = .disk,
.index = .ram,
.name = "3M accounts (3_slot - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 500_000,
.slot_list_len = 1,
.accounts = .disk,
.n_accounts_multiple = 2, // 1 mill accounts init
.index = .ram,
.name = "3M accounts (3_slot - ram index - disk accounts)",
},

// testing disk indexes
BenchArgs{
.n_accounts = 500_000,
.n_accounts = 100_000,
.slot_list_len = 1,
.accounts = .disk,
.accounts = .ram,
.index = .disk,
.name = "500k accounts (1_slot - disk index - disk accounts)",
.name = "100k accounts (1_slot - disk index - ram accounts)",
},
BenchArgs{
.n_accounts = 3_000_000,
.n_accounts = 100_000,
.slot_list_len = 1,
.accounts = .disk,
.index = .disk,
.name = "3m accounts (1_slot - disk index - disk accounts)",
.index = .ram,
.name = "100k accounts (1_slot - ram index - disk accounts)",
},
BenchArgs{
.n_accounts = 500_000,
.n_accounts = 100_000,
.slot_list_len = 1,
.accounts = .disk,
.index = .disk,
.n_accounts_multiple = 2,
.name = "500k accounts (1_slot - disk index - disk accounts)",
.name = "100k accounts (1_slot - disk index - disk accounts)",
},

// // test accounts in ram
// BenchArgs{
// .n_accounts = 100_000,
// .slot_list_len = 1,
// .accounts = .ram,
// .index = .ram,
// .name = "100k accounts (1_slot - ram index - ram accounts)",
// },
// BenchArgs{
// .n_accounts = 10_000,
// .slot_list_len = 10,
// .accounts = .ram,
// .index = .ram,
// .name = "10k accounts (10_slots - ram index - ram accounts)",
// },

// // tests large number of accounts on disk
// BenchArgs{
// .n_accounts = 10_000,
// .slot_list_len = 10,
// .accounts = .disk,
// .index = .ram,
// .name = "10k accounts (10_slots - ram index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 500_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .index = .ram,
// .name = "500k accounts (1_slot - ram index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 500_000,
// .slot_list_len = 3,
// .accounts = .disk,
// .index = .ram,
// .name = "500k accounts (3_slot - ram index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 3_000_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .index = .ram,
// .name = "3M accounts (1_slot - ram index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 3_000_000,
// .slot_list_len = 3,
// .accounts = .disk,
// .index = .ram,
// .name = "3M accounts (3_slot - ram index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 500_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .n_accounts_multiple = 2, // 1 mill accounts init
// .index = .ram,
// .name = "3M accounts (3_slot - ram index - disk accounts)",
// },

// // testing disk indexes
// BenchArgs{
// .n_accounts = 500_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .index = .disk,
// .name = "500k accounts (1_slot - disk index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 3_000_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .index = .disk,
// .name = "3m accounts (1_slot - disk index - disk accounts)",
// },
// BenchArgs{
// .n_accounts = 500_000,
// .slot_list_len = 1,
// .accounts = .disk,
// .index = .disk,
// .n_accounts_multiple = 2,
// .name = "500k accounts (1_slot - disk index - disk accounts)",
// },
};

pub fn readAccounts(bench_args: BenchArgs) !u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/cmd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const requestIpEcho = @import("../net/echo.zig").requestIpEcho;
const servePrometheus = @import("../prometheus/http.zig").servePrometheus;
const parallelUnpackZstdTarBall = @import("../accountsdb/snapshots.zig").parallelUnpackZstdTarBall;
const downloadSnapshotsFromGossip = @import("../accountsdb/download.zig").downloadSnapshotsFromGossip;
const SOCKET_TIMEOUT_US = @import("../net/socket_utils.zig").SOCKET_TIMEOUT_US;
const SOCKET_TIMEOUT_MS = @import("../net/socket_utils.zig").SOCKET_TIMEOUT_MS;

const config = @import("config.zig");
// var validator_config = config.current;
Expand Down Expand Up @@ -418,7 +418,7 @@ fn validator() !void {
// repair
var repair_socket = try Socket.create(network.AddressFamily.ipv4, network.Protocol.udp);
try repair_socket.bindToPort(repair_port);
try repair_socket.setReadTimeout(SOCKET_TIMEOUT_US);
try repair_socket.setReadTimeout(SOCKET_TIMEOUT_MS);

var repair_svc = try initRepair(
logger,
Expand Down
16 changes: 8 additions & 8 deletions src/gossip/service.zig
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub const GossipService = struct {
const gossip_address = my_contact_info.getSocket(socket_tag.GOSSIP) orelse return error.GossipAddrUnspecified;
var gossip_socket = UdpSocket.create(.ipv4, .udp) catch return error.SocketCreateFailed;
gossip_socket.bindToPort(gossip_address.port()) catch return error.SocketBindFailed;
gossip_socket.setReadTimeout(socket_utils.SOCKET_TIMEOUT_US) catch return error.SocketSetTimeoutFailed; // 1 second
gossip_socket.setReadTimeout(socket_utils.SOCKET_TIMEOUT_MS) catch return error.SocketSetTimeoutFailed; // 1 second

const failed_pull_hashes = HashTimeQueue.init(allocator);
const push_msg_q = ArrayList(SignedGossipData).init(allocator);
Expand Down Expand Up @@ -2933,27 +2933,27 @@ pub const BenchmarkGossipServiceGeneral = struct {

pub const args = [_]BenchmarkArgs{
.{
.name = "10k_ping_msgs",
.name = "5k_ping_msgs",
.message_counts = .{
.n_ping = 10_000,
.n_ping = 5_000,
.n_push_message = 0,
.n_pull_response = 0,
},
},
.{
.name = "10k_push_msgs",
.name = "5k_push_msgs",
.message_counts = .{
.n_ping = 0,
.n_push_message = 10_000,
.n_push_message = 5_000,
.n_pull_response = 0,
},
},
.{
.name = "10k_pull_resp_msgs",
.name = "1k_pull_resp_msgs",
.message_counts = .{
.n_ping = 0,
.n_push_message = 0,
.n_pull_response = 10_000,
.n_pull_response = 1_000,
},
},
};
Expand Down Expand Up @@ -3050,10 +3050,10 @@ pub const BenchmarkGossipServiceGeneral = struct {
var timer = try std.time.Timer.start();
while (true) {
const v = gossip_service.stats.gossip_packets_processed.get();
std.debug.print("{d} messages processed\r", .{v});
if (v >= msg_sent) {
break;
}
std.debug.print("{d} messages processed\r", .{v});
}
const elapsed = timer.read();
std.debug.print("\r", .{});
Expand Down
Loading

0 comments on commit 4a84670

Please sign in to comment.