Skip to content

alfred: Use bitmap to store dataset change events

Sven Eckelmann batman 1 version Applied

Status from this message: Thanks, applied this series

Get series with b4
b4 am 13899415.9hl4lahuAs@sven-edge

Versions newest first

  1. v1 Latest2 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2alfred: Use constant to define data type rangemain.c packet.h+5 -20 replies
2/2alfred: Use bitmap to store dataset change eventsalfred.h bitops.h main.c +1 more+401 -310 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [B.A.T.M.A.N.] [PATCH 0/2] alfred: Use bitmap to store dataset change events

Hi,

the --update-command implementation looked quite memory inefficient to me and I have therefore replaced it using a simple bit map which stores in BIT(i) when datatype I was modified. Here from the second patch:

Quoted 15 lines

The implementation for --update-command uses a double linked list to store the detected modifications of datasets. This implementation requires 24 bytes (1 byte data type, 7 bytes padding, 16 bytes linked list pointers) on amd64 for each element of the list. Each modified dataset type requires an own list item. Each list item is allocated using malloc and therefore additional overhead for the libc allocator information has also to be stored next to it. The list head uses a similar amount of memory (16 byte list pointers, 2 byte counter, 6 byte padding) but doesn't require additional allocations.

The list based implementation provides information about modified dataset type and the order in which these modifications were detected. But the latter is not actually required fr --update-command and can therefore be omitted.

Quoted 5 lines

A simple 256 bit wide storage element (32 bytes) is enough to keep the required information when only the detected modified data types have to be registered. BIT(i) is either 1 when dataset type i was modified or 0 when no modification was detected. This removes the (de)allocation CPU + memory overhead and avoids list searches when adding newly detected modifications.

The bitops.h file is used to implement the bit operations and keep the details away from the server code. I've reduced the size of the header file a little bit because most of it was not used by alfred.

Kind regards,
Sven

Sven Eckelmann (2):
alfred: Use constant to define data type range
alfred: Use bitmap to store dataset change events

 alfred.h |   4 +-
 bitops.h | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 main.c   |   9 +-
 packet.h |   1 +
 server.c |  46 ++++----
 5 files changed, 406 insertions(+), 33 deletions(-)
 create mode 100644 bitops.h