From 7bdbd63e0b0bd348aa22315ee791bf3e724baf2a Mon Sep 17 00:00:00 2001 From: Drew Nutter Date: Thu, 19 Dec 2024 08:44:19 -0300 Subject: [PATCH] perf(shred-network): reduce gossip lock hold time --- src/shred_network/turbine_tree.zig | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/shred_network/turbine_tree.zig b/src/shred_network/turbine_tree.zig index 53a72e9b2..f6ceb9a59 100644 --- a/src/shred_network/turbine_tree.zig +++ b/src/shred_network/turbine_tree.zig @@ -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(