-
Notifications
You must be signed in to change notification settings - Fork 227
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
fix for crash on windows in src/core/ev.c: initialze state->fromlen #1172
Conversation
before doing WSARecvFrom() to prevent crash (likely caused by the memcpy() of `state->from` at line 2301 with the memcpy length set to -1)
I wonder if this might be an incorrect commit (or maybe not precisely correct?). This slows down both |
I'm not saying "impossible", but I would be highly surprised if this commit causes the behavior you see here, as this should really change only affect code calling |
Current master: (for i 0 500_000_000)
elapsed 00:00:04.4632351 With #1172 reverted: (for i 0 500_000_000)
elapsed 00:00:03.9904488
I can't explain it either. |
Wow, that is pretty weird and amazing. So if you run on master and just comment out line 2323 in I can't seem to reproduce on neither Linux or cross-compiled Mingw though, so I'm not sure if I can help figure out what's happening here. |
I can confirm. Commenting out line 2323 on (var c (os/clock))
(for i 0 500_000_000)
(pp (- (os/clock) c)) |
Utter flabbergastery, especially since I am pretty much sure none of the code related to that |
I might have done something wrong, but I don't get such consistent results. I have compiled 2 different I put the code above in each window (though on a single line to get the timing to work out). My results vary quite a bit for each one - sometimes one is faster than the other and the results can differ by 6 seconds or so occasionally. I'll try again. |
One possible reason can be that unrelated changes in the code can cause other code to be moved and linked at different addresses, resulting in some critical loop ending up "wrongly" aligned for your particular machine/architecture, causing things to fall on the wrong side of the cache lines. This can sometimes dramatically affect performance and is amazingly hard to debug, prove, reproduce or fix. |
I wiped the build directories in each folder along with the Then I used I then started a REPL for each being careful to use The code pasted in each REPL was:
For master (5de8894), I got:
With the line commented out I get:
Subsequent invocations on one side just didn't end, so I stopped collecting info. Was reminded of this: https://www.youtube.com/watch?v=r-TLSBdHe1A |
Profiling can be very tricky; one thing to look out for is to give your test enough time to "wake up" your machine - it might be in some power saving mode with reduced clock frequency and take some time to get up to full speed; One trick is to this is to repeat your tests for a number of times in a tight loop and ignore the first results. |
Sounds awfully familiar :) My machine for Windows is a pretty weak one. I might try again tomorrow and try to collect info in a not-so-manual fashion. |
Feel free to disregard. On a different windows machine, I'm unable reproduce. Possibly only affects windows 10, but likely just something about that machine. |
Thanks for the update. Quite strange in any case! |
before doing WSARecvFrom() to prevent crash (likely caused by the memcpy() of
state->from
at line2301 with the memcpy length set to -1)