RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

core: limit message queue size

Open Kijewski opened this issue 12 years ago • 12 comments

Currently there can be up to 32k items in a message queue on 16bit platforms, and up to 2 billion items on 32 bit platforms. I don't think this is reasonable.

I would limit the message queue to 128 items. This reduces the size of cib_t (which is used in tcb_t) from 12 bytes to 4 bytes (including padding) on 32bit platforms.

If you think that 128 message queue items is too restrictive (I doubt it), then we can restrict the message queue to 32k items, which would shrink cib_t to 8 bytes.

But I don't think that the current limit of MAXINT / 2 is reasonable. At least it hurts portability.

Kijewski avatar Nov 26 '14 17:11 Kijewski

I agree that MAXINT / 2 is not reasonable for the message queue. I'm in doubt if 128 is enough for every use case.

OlegHahm avatar Nov 26 '14 17:11 OlegHahm

Should I open a PR to limit the fields of cib_t to uint16_t now, and we can discuss if uint8_t might be enough later?

Kijewski avatar Nov 26 '14 18:11 Kijewski

:+1:

OlegHahm avatar Nov 26 '14 22:11 OlegHahm

It doesn't look like the change to uint16_t was ever implemented. Should I submit a PR for this?

jhollister avatar Mar 05 '15 20:03 jhollister

I saw no one tackled this so I submitted a PR #2547

Darredevil avatar Mar 06 '15 13:03 Darredevil

PR was merged prematurely

LudwigKnuepfer avatar Mar 27 '15 21:03 LudwigKnuepfer

Imho, the performance aspect is more important here than saving some extra bytes of memory. I haven't testet it, but according to some posts on the internet accessing smaller datatypes (char, uint8_t, short,...) is slower than accessing unsigned/int on some 32-Bit ARM platforms - at least when unaligned. The current implementation looks good to me, I would rather leave it the way it is.

As this is marked as a "Newbie Task", please keep in mind integer conversion rules when refactoring: https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules

mlohse avatar Nov 23 '17 09:11 mlohse

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

stale[bot] avatar Aug 15 '19 09:08 stale[bot]

@kaspar030 do you think this is still an issue / should be fixed?

miri64 avatar Aug 27 '19 16:08 miri64

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

stale[bot] avatar Feb 28 '20 16:02 stale[bot]

@kaspar030 ping?

miri64 avatar Mar 03 '20 12:03 miri64

No real engagement for over three years and there are doubts regarding the performance of such a memory optimization. Let's close it. Reopen if you disagree.

miri64 avatar Jun 30 '20 09:06 miri64