Interactions-HSG / uArm-Controller

MIT License
1 stars 0 forks source link

Rationale behind the static allocation of 256 profiles #14

Closed iomz closed 3 years ago

iomz commented 3 years ago

We discussed this several times in the past, but I cannot remember precisely why we'd rather preallocate 256 profiles and iterate all of them in the main loop, rather than dynamically allocating memory for each profile upon registration and maintaining a single linked list of the profiles.

I think at the moment both memory footprint and overhead of accessing 256 profile_manager.events are enormous, but I guess this came from something related to delegating the profile ID management to the "gateway" and to saving memory space for storing the ID...?

iomz commented 3 years ago

As a memorandum I'm answering this to myself; it has the static allocation because

@jo-bru Is it correct?

jo-bru commented 3 years ago

Exactly, the profile index (profile_id) is used on the controller-level as a unique identifier for all profiles/devices. The profile index to GIAI/UUID mapping will be done in the gateway. The reasons for using a statically allocated array to store the profiles on the controller are:

As for now, we use about 60% of the available RAM, if the available space gets too small in the future, we can decrease the maximum number of profiles (now 256, which is IMO far too much). We may want to extend this in a future version to be able to dynamically change the maximum number of profiles with a request.

iomz commented 3 years ago

Thank you!