Performance optimizations in console parser and FindUniq#139
Open
jason-ni-0 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On configs with larger cardinality of consoles, ReReadCfg blocks the master's select loop for minutes per SIGHUP, hanging all new client connects. Two independent O(N^2) bottlenecks in the parse path: (1) ConsoleEnd calls FindParserDefaultOrConsole on the growing parserConsoles list for duplicate name detection; added a parallel hash table keyed on ->server for O(1) lookup, populated/cleared alongside the existing list. (2)
In the IPv6 path, FindUniq did a recursive O(N^2) dedup with two getaddrinfo() calls per pair; rewrote iteratively to resolve each unique master hostname once and track uniqHead via a parallel index array for O(uniqCount) inner lookup.
This change also fixes a latent bug in the original sockaddr compare which memcmp &rp->ai_addr (pointer-to-pointer) against sizeof(sockaddr_storage) instead of *rp->ai_addr with the family-appropriate length. Both changes are pure speedups with semantically identical output, so shouldnt have functionality changes.