Skip to content
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

ringbuf: allow opting out of entry de-duplication #1733

Merged
merged 6 commits into from
Apr 11, 2024
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Apr 5, 2024

Ringbuf entry de-duplication may help a lot of people fit more entries
in their ringbuffers, but it also generates a lot of PartialEq
comparisons, so it's impossible to say if it's good or bad, actually.

Therefore, this branch adds a mechanism for code which does not record a
lot of duplicate entries to opt out of de-duplication by adding a
no_dedup argument to the ringbuf! and counted_ringbuf! macros.
Currently, I haven't actually changed any tasks to actually use this;
I'd prefer to do it in a follow-up PR. However, when de-duplication is
disabled globally, there's a noticable size difference for several
tasks, as seen below:

Ringbuf de-duplication enabled
PROGRAM       REGION  USED   SIZE   LIMIT
kernel        flash   24736  24736  (fixed)
              ram     4212   5120   (fixed)
jefe          flash   7800   8192   16384
              ram     1808   2048   2048
sys           flash   2640   4096   (auto)
              ram     1476   2048   (auto)
i2c_driver    flash   11720  12288  16384
              ram     3228   4096   4096
packrat       flash   5860   5888   8192
              ram     1720   2048   2048
spi_driver    flash   12000  12032  16384
              ram     1908   2048   4096
net           flash   44768  45056  131072
              ram     10604  16384  16384
              sram1   12416  16384  32768
user_leds     flash   1492   1504   2048
              ram     964    1024   1024
user_button   flash   1148   1152   (auto)
              ram     1220   2048   (auto)
udpecho       flash   8640   8640   32768
              ram     4428   8192   8192
udpbroadcast  flash   8440   8448   16384
              ram     4488   8192   8192
udprpc        flash   10796  10816  32768
              ram     4424   8192   8192
hiffy         flash   24420  24576  32768
              ram     29428  32768  32768
hf            flash   12276  12288  16384
              ram     2340   4096   4096
hash_driver   flash   8388   8416   16384
              ram     2244   4096   4096
idle          flash   84     96     128
              ram     256    256    256
rng_driver    flash   6320   6336   8192
              ram     452    512    512
dump_agent    flash   8648   8704   32768
              ram     1904   2048   2048
fmc_demo      flash   7720   8192   (auto)
              ram     1136   2048   (auto)
Ringbuf de-duplication enabled
PROGRAM       REGION  USED   SIZE   LIMIT
kernel        flash   24736  24736  (fixed)
              ram     4212   5120   (fixed)
jefe          flash   8392   8448   16384
              ram     1856   2048   2048
sys           flash   2640   4096   (auto)
              ram     1476   2048   (auto)
i2c_driver    flash   12904  16384  16384
              ram     4060   4096   4096
packrat       flash   6124   6144   8192
              ram     1720   2048   2048
spi_driver    flash   12372  12384  16384
              ram     2164   4096   4096
net           flash   44768  45056  131072
              ram     10604  16384  16384
              sram1   12416  16384  32768
user_leds     flash   1492   1504   2048
              ram     964    1024   1024
user_button   flash   1264   1280   (auto)
              ram     1284   2048   (auto)
udpecho       flash   8640   8640   32768
              ram     4428   8192   8192
udpbroadcast  flash   8440   8448   16384
              ram     4488   8192   8192
udprpc        flash   10796  10816  32768
              ram     4424   8192   8192
hiffy         flash   24916  24928  32768
              ram     29684  32768  32768
hf            flash   12276  12288  16384
              ram     2340   4096   4096
hash_driver   flash   8388   8416   16384
              ram     2244   4096   4096
idle          flash   84     96     128
              ram     256    256    256
rng_driver    flash   6320   6336   8192
              ram     452    512    512
dump_agent    flash   8648   8704   32768
              ram     1904   2048   2048
fmc_demo      flash   7720   8192   (auto)
              ram     1136   2048   (auto)

@bcantrill
Copy link
Collaborator

bcantrill commented Apr 5, 2024

I would prefer this to be opt-out rather than opt-in, but if it is to be opt-in please make sure i2c_driver and gimlet_seq are both opted in.

@hawkw
Copy link
Member Author

hawkw commented Apr 5, 2024

I would prefer this to be opt-out rather than opt-in, but if it is to be opt-in please make sure i2c_driver and gimlet_seq are both opted in.

We can do opt-in instead! The main reason I started with it opted out is because I wanted to see what the code size impact was for globally disabling de-duplication; I'm not attached to this being the final form of the API.

@hawkw hawkw changed the title ringbuf: make de-duplication opt in ringbuf: make de-duplication opt-in Apr 8, 2024
@hawkw hawkw changed the title ringbuf: make de-duplication opt-in ringbuf: allow opting out of entry de-duplication Apr 8, 2024
@hawkw hawkw marked this pull request as ready for review April 8, 2024 21:47
@hawkw hawkw requested review from cbiffle and bcantrill April 8, 2024 21:47
Copy link
Collaborator

@cbiffle cbiffle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that you've factored out the count type, so we could potentially use bigger or smaller counters in certain cases in the future.

@hawkw hawkw enabled auto-merge (squash) April 11, 2024 23:10
@hawkw hawkw disabled auto-merge April 11, 2024 23:29
@hawkw hawkw enabled auto-merge (squash) April 11, 2024 23:29
@hawkw hawkw merged commit 8f30349 into master Apr 11, 2024
103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants