Skip to content

Commit

Permalink
ConcurrentDictionary and ToFrozenDictionary are not friends
Browse files Browse the repository at this point in the history
  • Loading branch information
ZingBallyhoo committed Nov 18, 2024
1 parent 6e0ae3f commit 62502d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion TACTLib/Protocol/CDNIndexHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ private CDNIndexHandler(ClientHandler client)
// converting to a frozen dictionary afterwards helps a bit but the arrays are still wasteful
// also means the peak memory is higher during conversion
// using IDictionary is also worse for lookup perf, but this keeps the code simpler for now
CDNIndexData = CDNIndexData.ToFrozenDictionary(CASCKeyComparer.Instance);
// we could load each index into an array of entries and then merge sort into one giant array...
// (also means higher building memory cost but maybe that's inevitable)

if (!client.CreateArgs.ParallelCDNIndexLoading)
{
// ToFrozenDictionary doesn't like ConcurrentDictionary
// before processing it internally converts it to a normal Dictionary
// for a dictionary with 9 million entries, this is a perf disaster
CDNIndexData = CDNIndexData.ToFrozenDictionary(CASCKeyComparer.Instance);
}
}

private bool LoadGroupIndexFile(string hash) {
Expand Down

0 comments on commit 62502d4

Please sign in to comment.