You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the read data path, we had many checks like:
if errors.Is(err, io.EOF) {
return nil
}
There are 2 issues with these checks:
1. io.Copy() is documented to never return io.EOF, and current code
matches the docs.
2. errors.Is() is expensive and should not be used in the fast path
This change remove the checks when they are not needed, and it the case
of handling Recv() which is documented to return io.EOF, or
PacketCon.ReadFrom() which does not mention io.EOF semantics, move the
check into a err != nil block.
I did not make any measurements with lima, but dolthub.com did synthetic
benchmarks:
https://www.dolthub.com/blog/2024-05-31-benchmarking-go-error-handling/
Based on the benchmarks the difference in the case when err == nil is
not big, but the code is more clear when we gather all error handling
under a err != nil check.
Signed-off-by: Nir Soffer <[email protected]>
0 commit comments