Skip to content

Commit

Permalink
perf(shred-network): reduce gossip lock hold time
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed Dec 19, 2024
1 parent 4570ab4 commit 7bdbd63
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/shred_network/turbine_tree.zig
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ pub const TurbineTree = struct {
staked_nodes: *const std.AutoArrayHashMapUnmanaged(Pubkey, u64),
use_stake_hack_for_testing: bool,
) !TurbineTree {
const gossip_table, var gossip_table_lg = gossip_table_rw.readWithLock();
defer gossip_table_lg.unlock();

const gossip_peers = try gossip_table.getThreadSafeContactInfosMatchingShredVersion(
allocator,
&my_contact_info.pubkey,
my_contact_info.shred_version,
0,
);
const gossip_peers = blk: {
const gossip_table, var gossip_table_lg = gossip_table_rw.readWithLock();
defer gossip_table_lg.unlock();

break :blk try gossip_table.getThreadSafeContactInfosMatchingShredVersion(
allocator,
&my_contact_info.pubkey,
my_contact_info.shred_version,
0,
);
};
defer gossip_peers.deinit();

const nodes = try collectTvuAndStakedNodes(
Expand Down

0 comments on commit 7bdbd63

Please sign in to comment.