-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve benchmarks and errors #421
Conversation
Benchmarks between this and the current main branch are discontinuous, i.e. the tests have changed enough that any change in values is (mostly†) purely noise. †: There is a small change here that has a surprising impact on performance. Removing the |
I have noticed the same thing in other projects in the past, it is precisely for this reason that in #407 I wrote:
|
Just out of curiosity, do you have a figure on that? I just took a diff of the asm, and the only differences are a memory access that should go to the L1 cache and a predictable jump. |
Generating benchmarks now… |
old is with the
I‘ve cut out most of the metrics, because they’re largely the same. Actually, things are looking generally so fast that the difference that are there look to be mostly just noise. I would be more inclined to trust the smaller buffer ones, as they have more time/op (more transfers means more of this one tiny code change having any effect). But then also maybe confirmation bias. I do think the most interesting thing here is the massive variance at the 32k buffer for both the read and write. Even though it’s a massive 2ms to the new one, the variance is so massive there’s no way to say for sure it’s because of this code change. So, nothing spectacular, but I still think “nocode is best code” is still controlling anyways. Nothing massive, but still a better choice anyways. (More interesting, removing this opens up the possibility of moving the mutex later to just the writing, meaning the packet marshal times can potentially overlap. That might be where I saw the big boost that I spoke of above.) |
🤔 A good idea. Have all of them implement |
With no objections, let’s merge this? |
Ahead of some other improvements, I wanted to narrow the benchmarks to only relevant code, and this allow necessitated fixing some tests to go along with it.
Fixes:
errors.Errorf("constant string")
have been replaced witherrors.New("constant string")
errors.Errorf("constant string: %v", err)
have been replaced witherrors.Wrap(err, "constant string")
sftp.clientConn.conn.sendPacketTest
has been replaced with atimeBombWriter
, this removes unnecessary test code fromconn
err != errFakeNet
have been replaced with!errors.Is(err, errFakeNet)
, this works because we are now properly wrapping errors.%v
formatting codes that can be more type-safe have been made to be more type specific.runSftpClient
’scmd.Wait
have been put into anexecErr
type that wraps the underlying error.packet_test.go
has a lot of changes:'c'
to make the value clear.TestRecvPacket
now tests a the short-packet behavior, and the long-packet behavior.ioutil.Discard
as we do not want to benchmarkbytes.Buffer
, we want to benchmark our marshaling code.