-
Notifications
You must be signed in to change notification settings - Fork 2k
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
net/coap: Block optimizations #11057
Conversation
789646e
to
b2c9080
Compare
Rebased, including replacement of functionality in #11802 with the implementation here. |
This one needs a rebase. |
b2c9080
to
c1aa872
Compare
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.
Some comments, otherwise I ran the functional tests and there seems to be no regression
sudo -E pytest block1_server_test.py
========================================================= test session starts ==========================================================
platform linux -- Python 3.6.8, pytest-5.1.3, py-1.8.0, pluggy-0.12.0
rootdir: /home/francisco/workspace/riot-coap-pytest, inifile: pytest.ini
collected 6 items
block1_server_test.py ...... [100%]
========================================================== 6 passed in 25.57s ==========================================================
sudo -E pytest block2_server_test.py
========================================================= test session starts ==========================================================
platform linux -- Python 3.6.8, pytest-5.1.3, py-1.8.0, pluggy-0.12.0
rootdir: /home/francisco/workspace/riot-coap-pytest, inifile: pytest.ini
collected 4 items
block2_server_test.py .... [100%]
========================================================== 4 passed in 16.94s ==========================================================
sudo -E pytest block1_client_test.py
========================================================= test session starts ==========================================================
platform linux -- Python 3.6.8, pytest-5.1.3, py-1.8.0, pluggy-0.12.0
rootdir: /home/francisco/workspace/riot-coap-pytest, inifile: pytest.ini
collected 1 item
block1_client_test.py . [100%]
========================================================== 1 passed in 0.84s ===========================================================
sudo -E pytest block2_client_test.py
========================================================= test session starts ==========================================================
platform linux -- Python 3.6.8, pytest-5.1.3, py-1.8.0, pluggy-0.12.0
rootdir: /home/francisco/workspace/riot-coap-pytest, inifile: pytest.ini
collected 3 items
block2_client_test.py ... [100%]
========================================================== 3 passed in 2.62s ===========================================================
@@ -1216,7 +1245,12 @@ size_t coap_put_option(uint8_t *buf, uint16_t lastonum, uint16_t onum, const uin | |||
* | |||
* @returns amount of bytes written to @p buf | |||
*/ | |||
size_t coap_put_option_block1(uint8_t *buf, uint16_t lastonum, unsigned blknum, unsigned szx, int more); | |||
static inline size_t coap_put_option_block1(uint8_t *buf, uint16_t lastonum, |
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 we change this to coap_put_option_block()
? and add option as a parameter?
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.
How about actually deprecating this function in favor of using coap_opt_put_block1_control(), which already is used in the nanocoap_server example? One of my goals with this sequence of PRs was consistent names for block functions.
Either way, I would like to put the deprecation in a separate PR.
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.
+1
@kb2ma once the final two comments are addressed feel free to squash :) and trigger the ci build |
12518ae
to
5018e2c
Compare
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.
Blocking until I get a fix in for _size2szx().
/* Size exponent + 1 */ | ||
assert(szx >= 5); | ||
return szx - 5; | ||
return bitarithm_lsb(size) - 4; |
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.
I think I was too aggressive by returning here. I'd like to restore the assert on the szx value. I'll add in a fix.
Apologies for the churn.
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.
ok!
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.
Just pushed the fixup. Also added a comment to explain the sequencing of the offset subtraction.
@kb2ma Tests are still passing, please squash. |
c49c8f4
to
2dc4209
Compare
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.
Thanks for all the testing and feedback with these PRs, @fjmolinas! |
size_t coap_opt_put_block_object(uint8_t *buf, uint16_t lastonum, | ||
coap_block1_t *block, uint16_t option); | ||
size_t coap_opt_put_uint(uint8_t *buf, uint16_t lastonum, uint16_t onum, | ||
uint32_t value); |
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.
Shouldn't this also pass the remaining space available in buf
so we don't silently overflow?
Contribution description
While working on the Block implementation (#10732) we found several opportunities for optimization. However, we decided to wait until the implementation was complete before implementing them. This PR includes the improvements listed below.
This PR also completes the Block implementation!
Testing procedure
Verify no regression by rerunning the test procedure in #11024 and #11056.
Issues/PRs references
Completes #10732.