net: make SplitHostPort alloc-free in more cases#78398
net: make SplitHostPort alloc-free in more cases#78398jub0bs wants to merge 1 commit intogolang:masterfrom
Conversation
|
This PR (HEAD: ea71385) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/760021. Important tips:
|
ea71385 to
aca3ddc
Compare
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
Message from jub0bs: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
This PR (HEAD: aca3ddc) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/760021. Important tips:
|
|
Message from Damien Neil: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
Message from jub0bs: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
Message from Damien Neil: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
Because SplitHostPort is not inlineable, its error result cannot benefit from mid-stack inlining and must be moved to the heap. However, callers of SplitHostPort that only use its error result in nil checks are pretty typical, and their performance needlessly suffers from the resulting allocation. Drawing inspiration from CL 734440, this CL refactors SplitHostPort to an inlineable wrapper around a function that returns, not an error, but the concrete type of SplitHostPort's error result. Consequently, that error result can stay on the stack in cases where callers only use it in nil checks, and SplitHostPort is now allocation-free for such callers. To clarify: the goal of this CL is to make SplitHostPort allocation-free, not simply in non-error cases, but also in error cases in which the error result is only used in nil checks.
aca3ddc to
ca9b9c9
Compare
|
This PR (HEAD: ca9b9c9) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/760021. Important tips:
|
|
Message from jub0bs: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
Message from jub0bs: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
|
Message from jub0bs: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/760021. |
Because SplitHostPort is not inlineable, its error result cannot benefit
from mid-stack inlining and must be moved to the heap. However, callers
of SplitHostPort that only use its error result in nil checks are pretty
typical, and their performance needlessly suffers from the resulting
allocation.
Drawing inspiration from CL 734440, this CL refactors SplitHostPort to
an inlineable wrapper around a function that returns, not an error, but
the concrete type of SplitHostPort's error result. Consequently, that
error result can stay on the stack in cases where callers only use it in
nil checks, and SplitHostPort is now allocation-free for such callers.
To clarify: the goal of this CL is to make SplitHostPort
allocation-free, not simply in non-error cases, but also in error cases
in which the error result is only used in nil checks.