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(gossip): reduce gossip table memory usage #526

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
21 changes: 20 additions & 1 deletion src/gossip/data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub const GossipKey = union(GossipDataTag) {
RestartHeaviestFork: Pubkey,
};

const GossipDataTag = enum(u32) {
pub const GossipDataTag = enum(u32) {
LegacyContactInfo,
Vote,
LowestSlot,
Expand All @@ -191,6 +191,25 @@ const GossipDataTag = enum(u32) {
ContactInfo,
RestartLastVotedForkSlots,
RestartHeaviestFork,

pub fn Value(self: GossipDataTag) type {
0xNineteen marked this conversation as resolved.
Show resolved Hide resolved
return switch (self) {
.LegacyContactInfo => LegacyContactInfo,
.Vote => struct { u8, Vote },
.LowestSlot => struct { u8, LowestSlot },
.LegacySnapshotHashes => LegacySnapshotHashes,
.AccountsHashes => AccountsHashes,
.EpochSlots => struct { u8, EpochSlots },
.LegacyVersion => LegacyVersion,
.Version => Version,
.NodeInstance => NodeInstance,
.DuplicateShred => struct { u16, DuplicateShred },
.SnapshotHashes => SnapshotHashes,
.ContactInfo => ContactInfo,
.RestartLastVotedForkSlots => RestartLastVotedForkSlots,
.RestartHeaviestFork => RestartHeaviestFork,
};
}
};

/// Analogous to [CrdsData](https://github.com/solana-labs/solana/blob/e0203f22dc83cb792fa97f91dbe6e924cbd08af1/gossip/src/crds_value.rs#L85)
Expand Down
4 changes: 3 additions & 1 deletion src/gossip/dump_service.zig
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ pub const GossipDumpService = struct {

// write records to string
const endec = base58.Table.BITCOIN;
for (gossip_table.store.values()) |gossip_versioned_data| {
var iterator = gossip_table.store.iterator();
while (iterator.next()) |entry| {
const gossip_versioned_data = entry.getVersionedData();
const val: SignedGossipData = gossip_versioned_data.value;

var encoded_buf: [50]u8 = undefined;
Expand Down
1 change: 1 addition & 0 deletions src/gossip/lib.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub const active_set = @import("active_set.zig");
pub const data = @import("data.zig");
pub const dump_service = @import("dump_service.zig");
pub const map = @import("map.zig");
pub const message = @import("message.zig");
pub const ping_pong = @import("ping_pong.zig");
pub const pull_request = @import("pull_request.zig");
Expand Down
Loading