Skip to content

Reducing MOAS consumer memory consumption#12

Draft
digizeph wants to merge 7 commits intomasterfrom
moas-memory
Draft

Reducing MOAS consumer memory consumption#12
digizeph wants to merge 7 commits intomasterfrom
moas-memory

Conversation

@digizeph
Copy link
Contributor

This PR contains code changes to bvc_moas.c targeted to reduce the memory consumption of the MOAS consumer.

The main change is that I changed the moas_signature struct to use a combination of small static allocated array and a large dynamically allocated array, instead of always using max-size statically allocated array.

For the most of the MOAS events, the number of origins within is less than 4 ASes (85 percentile at the time of PR). Therefore we use 4 as the size of the static array. If there are more than 4 origins in the event, we will allocate an array of size 128 to accommodate the extreme cases.

Room for further improvement:

  • instead of always allocate 128 origins when greater than 4, we can consider allocate a step at a time. however, this complicates the complexity of the code considerably.

remove `moas_signature` parameter as it was not used in the current
version of the `log_moas` function
the `moas_signature` struct changes from containing a static allocated
int32 array of size 128 and a count integer, to a static array of size 4
and a dynamic array and a origins count. the dynamic array is allocated
if there are more than 4 origins in the moas event and is assigned with
a static 128 size.

this commit is designed to reduce the memory consumption of the moas
consumer by reducing the sizes of the moas signatures needed to be
stored in memory.
every time we try to write to array location outside the current range,
we expand the space by MAX_STATIC_ORIGINS
this simplifies the flow for extending the dynamic array size
@digizeph digizeph marked this pull request as draft August 4, 2020 20:39
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.

1 participant