Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(rpc): io_uring integration & redesign #477

Merged
merged 25 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c6e3a44
RPC server: io_uring upgrade
InKryption Jan 9, 2025
7d5e396
Don't use file-as-struct
InKryption Jan 20, 2025
a61ca09
Run style script, respect line length limit
InKryption Jan 20, 2025
e181f1d
Improve accept failure handling & update TODOs
InKryption Jan 21, 2025
a33162d
Add TODO to remove hacky-ish workaround
InKryption Jan 21, 2025
a14c87b
Use `self: Type` convention
InKryption Jan 23, 2025
7ae80c1
A few minor fixups and improvements
InKryption Jan 24, 2025
642bb83
Simplify test, make server socket nonblocking
InKryption Jan 24, 2025
6de1c00
server.zig -> server/lib.zig
InKryption Jan 27, 2025
733cb36
Segregate out the basic backend
InKryption Jan 27, 2025
142214a
Re-organize server module
InKryption Jan 27, 2025
2e469d0
Update LOGGER_SCOPE
InKryption Jan 27, 2025
871791d
Simplify & improve io_uring backend error handling
InKryption Jan 28, 2025
b9c91d3
De-scope `accept_flags`
InKryption Feb 3, 2025
b1bf268
Simplify `can_use` for linux cross-compilation
InKryption Feb 3, 2025
e4c2090
(io_uring) Rework error handling, add timeout
InKryption Feb 4, 2025
ef0eb3b
(io_uring) Remove multishot_accept_submitted
InKryption Feb 4, 2025
f2850a1
(io_uring) Simplify new entry creation
InKryption Feb 4, 2025
a62bd8c
Misc fixups
InKryption Feb 5, 2025
b180b08
Re-organize alias/import
InKryption Feb 5, 2025
0a019a5
General restructure
InKryption Feb 6, 2025
2708dd9
Re-oorganize loggers & scopes
InKryption Feb 10, 2025
ff55d3f
Refactor `build_options` imports
InKryption Feb 10, 2025
1566938
Add `no_network_tests` build option
InKryption Feb 10, 2025
fb5963e
Update circleci with `-Dno-network-tests`
InKryption Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ jobs:
key: linux-x86_64-0.13.0-{{ checksum "build.zig.zon" }}-v6
- run:
name: Test
command: workspace/zig/zig build test -Dcpu=x86_64_v3 -Denable-tsan=true --color off --summary all
# Disable network-accessing tests for this job, which behave badly on circleci
command: workspace/zig/zig build test -Dcpu=x86_64_v3 -Denable-tsan=true -Dno-network-tests --color off --summary all

test_kcov_linux:
executor: linux-executor
Expand All @@ -165,7 +166,7 @@ jobs:
key: linux-x86_64-0.13.0-{{ checksum "build.zig.zon" }}-v6
- run:
name: Build
command: workspace/zig/zig build test -Dcpu=x86_64_v3 -Denable-tsan=false -Dno-run --summary all
command: workspace/zig/zig build test -Dcpu=x86_64_v3 -Denable-tsan=false -Dno-run -Dno-network-tests --summary all
- run:
name: Test and Collect
command: |
Expand Down
2 changes: 2 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ pub fn build(b: *Build) void {
\\Don't install any of the binaries implied by the specified steps, only run them.
\\Use in conjunction with 'no-run' to avoid running as well.
) orelse false;
const no_network_tests = b.option(bool, "no-network-tests", "Do not run any tests that depend on the network.") orelse false;

// Build options
const build_options = b.addOptions();
build_options.addOption(BlockstoreDB, "blockstore_db", blockstore_db);
build_options.addOption(bool, "no_network_tests", no_network_tests);

// CLI build steps
const install_step = b.getInstallStep();
Expand Down
1 change: 1 addition & 0 deletions src/accountsdb/db.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3350,6 +3350,7 @@ test "testWriteSnapshot" {
);
}

/// Unpacks the snapshots from `sig.TEST_DATA_DIR`.
pub fn findAndUnpackTestSnapshots(
n_threads: usize,
/// The directory into which the snapshots are unpacked.
Expand Down
11 changes: 6 additions & 5 deletions src/accountsdb/snapshots.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ pub const FullSnapshotFileInfo = struct {
slot: Slot,
hash: Hash,

const SnapshotArchiveNameFmtSpec = sig.utils.fmt.BoundedSpec("snapshot-{[slot]d}-{[hash]s}.tar.zst");
pub const SnapshotArchiveNameFmtSpec = sig.utils.fmt.BoundedSpec("snapshot-{[slot]d}-{[hash]s}.tar.zst");

pub const SnapshotArchiveNameStr = SnapshotArchiveNameFmtSpec.BoundedArrayValue(.{
.slot = std.math.maxInt(Slot),
Expand Down Expand Up @@ -2341,7 +2341,7 @@ pub const IncrementalSnapshotFileInfo = struct {
};
}

const SnapshotArchiveNameFmtSpec = sig.utils.fmt.BoundedSpec("incremental-snapshot-{[base_slot]d}-{[slot]d}-{[hash]s}.tar.zst");
pub const SnapshotArchiveNameFmtSpec = sig.utils.fmt.BoundedSpec("incremental-snapshot-{[base_slot]d}-{[slot]d}-{[hash]s}.tar.zst");

pub const SnapshotArchiveNameStr = SnapshotArchiveNameFmtSpec.BoundedArrayValue(.{
.base_slot = std.math.maxInt(Slot),
Expand Down Expand Up @@ -2486,15 +2486,16 @@ pub const SnapshotFiles = struct {
full: FullSnapshotFileInfo,
incremental_info: ?SlotAndHash,

pub fn incremental(snapshot_files: SnapshotFiles) ?IncrementalSnapshotFileInfo {
const inc_info = snapshot_files.incremental_info orelse return null;
pub fn incremental(self: SnapshotFiles) ?IncrementalSnapshotFileInfo {
const inc_info = self.incremental_info orelse return null;
return .{
.base_slot = snapshot_files.full.slot,
.base_slot = self.full.slot,
.slot = inc_info.slot,
.hash = inc_info.hash,
};
}

/// Asserts that `if (maybe_incremental_info) |inc| inc.base_slot == full_info.slot`.
pub fn fromFileInfos(
full_info: FullSnapshotFileInfo,
maybe_incremental_info: ?IncrementalSnapshotFileInfo,
Expand Down
4 changes: 2 additions & 2 deletions src/ledger/blockstore.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const build_options = @import("build-options");
const sig = @import("../sig.zig");
const ledger = @import("lib.zig");

pub const BlockstoreDB = switch (build_options.blockstore_db) {
pub const BlockstoreDB = switch (sig.build_options.blockstore_db) {
.rocksdb => ledger.database.RocksDB(&ledger.schema.list),
.hashmap => ledger.database.SharedHashMapDB(&ledger.schema.list),
};
Expand Down
3 changes: 1 addition & 2 deletions src/ledger/cleanup_service.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const build_options = @import("build-options");
const std = @import("std");
const sig = @import("../sig.zig");
const ledger = @import("lib.zig");
Expand Down Expand Up @@ -461,7 +460,7 @@ test "findSlotsToClean" {
}
// When implementation is rocksdb, we need to flush memtable to disk to be able to assert.
// We do that by deiniting the current db, which triggers the flushing.
if (build_options.blockstore_db == .rocksdb) {
if (sig.build_options.blockstore_db == .rocksdb) {
db.deinit();
db = try TestDB.reuseBlockstore(@src());
reader.db = db;
Expand Down
1 change: 0 additions & 1 deletion src/ledger/database/hashmap.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const std = @import("std");
const sig = @import("../../sig.zig");
const database = @import("lib.zig");
const build_options = @import("build-options");

const Allocator = std.mem.Allocator;
const RwLock = std.Thread.RwLock;
Expand Down
3 changes: 1 addition & 2 deletions src/ledger/database/rocksdb.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const std = @import("std");
const rocks = @import("rocksdb");
const sig = @import("../../sig.zig");
const database = @import("lib.zig");
const build_options = @import("build-options");

const Allocator = std.mem.Allocator;

Expand Down Expand Up @@ -348,7 +347,7 @@ fn callRocks(logger: ScopedLogger(LOG_SCOPE), comptime func: anytype, args: anyt
}

comptime {
if (build_options.blockstore_db == .rocksdb) {
if (sig.build_options.blockstore_db == .rocksdb) {
_ = &database.interface.testDatabase(RocksDB);
}
}
5 changes: 2 additions & 3 deletions src/ledger/fuzz.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const std = @import("std");
const sig = @import("../sig.zig");
const build_options = @import("build-options");
const ledger = @import("lib.zig");

const ColumnFamily = sig.ledger.database.ColumnFamily;
Expand All @@ -19,7 +18,7 @@ const cf1 = ColumnFamily{

var executed_actions = std.AutoHashMap(Actions, void).init(allocator);

pub const BlockstoreDB = switch (build_options.blockstore_db) {
pub const BlockstoreDB = switch (sig.build_options.blockstore_db) {
.rocksdb => ledger.database.RocksDB(&.{cf1}),
.hashmap => ledger.database.SharedHashMapDB(&.{cf1}),
};
Expand Down Expand Up @@ -198,7 +197,7 @@ fn dbCount(
try executed_actions.put(Actions.count, {});
// TODO Fix why changes are not reflected in count with rocksdb implementation,
// but it does with hashmap.
if (build_options.blockstore_db == .rocksdb) {
if (sig.build_options.blockstore_db == .rocksdb) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/rpc/lib.zig
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
pub const client = @import("client.zig");
pub const server = @import("server.zig");
pub const server = @import("server/lib.zig");

pub const request = @import("request.zig");
pub const response = @import("response.zig");
pub const types = @import("types.zig");

pub const Client = client.Client;
pub const Server = server.Server;

pub const Request = request.Request;
pub const Response = response.Response;
Loading