-
Notifications
You must be signed in to change notification settings - Fork 440
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
Remove check macro #840
Remove check macro #840
Conversation
ec24b4d
to
afbe1a6
Compare
Codecov Report
@@ Coverage Diff @@
## main #840 +/- ##
==========================================
+ Coverage 79.39% 79.52% +0.13%
==========================================
Files 76 78 +2
Lines 27504 27848 +344
==========================================
+ Hits 21836 22147 +311
- Misses 5668 5701 +33
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show some example error messages from before and after this patch? Reading through the code, it looks as though it will differ.
afbe1a6
to
83234c6
Compare
Signed-off-by: Thibaut Vandervelden <thvdveld@vub.be>
83234c6
to
9a850cf
Compare
I don't have any logs to show where I had error messages. I would have to create fake packets for that. I removed the check macro, which was mostly used for unwrapping the checked and parsed packets. Now they return an error, which is captured in https://github.com/smoltcp-rs/smoltcp/pull/840/files#diff-9797218dceaf8c0bdfeddfab917f17b8d1028fd1e817a5b3de18bc4814fd894eR657-R729. Previously, the logging happened at each check macro, and I think the compiler was unable to optimize it. I did extra measurements: This is the server example on main, and I removed all the logging in the example such that I can disable the
This is the server example on this branch, also with all logging disabled:
As you can see, it's a bit bigger on this branch. If I enable the log feature, but with all the logging removed in the example, and on main:
The same but on this branch:
The difference is very noticeable. When all the logging is enabled (also in the example):
And on this branch:
We can see that the difference is again around 7kB. I think that with my changes, the logging of the messages is still the same, but just now only logging in one place instead of every time when the check macro is used. With these changes, I noticed that the PAN ID was not set for the examples. I noticed it with the |
@thvdveld My main question here is: If you've removed the |
Previously, all functions returned |
Okay. This makes sense to me in principle. I would really like another reviewer to sign off on the change because I'm honestly pretty tired and am not sure I'll spot everything. |
This PR reverts that, which I'm not sure is something we should do. Why is propagating errors up and ignoring them in a centralized place better than ignoring them when we get them? Also, it doesn't make sense to me that this reduces code size. It's strictly more code paths (previous code could return None, new code can also return Err). Are you sure it's not because of the |
But the return type for
If I disable all the logging, the binary sizes are equal (main branch vs this branch). This means that the impact of returning When logging is enabled, there is a difference of around 7000 bytes, which is not the same as the 460 bytes difference. I not able to explain why there is a change, since I think the behavior (main vs this branch) for the logging is the same.
True, however, a decrease of 7kB for just logging is a big impact if you want to run with traces enabled. |
If you want to actually act on errors returned from |
I don't understand this, I'm really sorry. How did my changes affect this? I didn't change anything in |
Removing the check macro and just returning using question mark operator reduces the size of the binary.
Server example (main):
Server example (now):
Sixlowpan example (main):
Sixlowpan example (now):