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

"new" memory allocator for LPs memory: DyMeLoR! #85

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft

Conversation

Piccions
Copy link
Contributor

@Piccions Piccions commented Oct 5, 2022

This PR reintroduces a rewritten version of the old memory allocator used in RS2 in the codebase.
From a limited evaluation this allocator seems to be often faster than the buddy-based one, even if it's a bit more memory intensive.
A huge problem of this PR is how to select of the memory allocator: I hope we can have a useful discussion about this.

Piccions added 2 commits June 20, 2022 02:27
Criticism and suggestions are always welcome!

Signed-off-by: Andrea Piccione <piccione@diag.uniroma1.it>
@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Merging #85 (d67b601) into develop (47b8225) will decrease coverage by 2.86%.
The diff coverage is 79.47%.

@@             Coverage Diff             @@
##           develop      #85      +/-   ##
===========================================
- Coverage    87.89%   85.02%   -2.87%     
===========================================
  Files           46       50       +4     
  Lines         2073     2545     +472     
  Branches        47       60      +13     
===========================================
+ Hits          1822     2164     +342     
- Misses         229      356     +127     
- Partials        22       25       +3     
Impacted Files Coverage Δ
src/mm/buddy/buddy.c 85.96% <ø> (ø)
src/mm/buddy/ckpt.c 100.00% <ø> (ø)
src/mm/msg_allocator.c 76.66% <ø> (ø)
test/tests/integration/phold.c 86.95% <ø> (ø)
src/mm/dymelor/checkpoint.c 63.63% <63.63%> (ø)
src/lp/process.c 74.85% <65.00%> (-0.84%) ⬇️
src/mm/model_allocator.c 79.04% <79.04%> (ø)
test/tests/mm/mm_hard.c 85.85% <84.21%> (ø)
src/mm/dymelor/dymelor.c 84.82% <84.82%> (ø)
src/mm/buddy/multi_buddy.c 88.99% <90.90%> (ø)
... and 27 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Oct 5, 2022

Documentation coverage is 68.1% 👍

Classes    : 100.0% (1/1)
Defines    :  71.3% (107/150)
Enum Values:  70.1% (47/67)
Enums      :  45.5% (5/11)
Files      :  89.3% (67/75)
Functions  :  68.4% (256/374)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (3/3)
Structs    :  84.0% (21/25)
Typedefs   :  91.7% (11/12)
Variables  :  55.6% (119/214)
-----------------------------------
Total      :  68.1% (637/935)


area->alloc_chunks = ackpt->chunk_cnt;
size_t bitmap_size = bitmap_required_size(num_chunks);
memcpy(area->use_bitmap, ackpt->data, bitmap_size);

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
ackpt->i = i;
ackpt->chunk_cnt = area->alloc_chunks;
size_t bitmap_size = bitmap_required_size(num_chunks);
memcpy(ackpt->data, area->use_bitmap, bitmap_size);

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

#define copy_from_area(x) \
({ \
memcpy(ptr, area->area + ((x) * (chunk_size + sizeof(uint_least32_t))), chunk_size); \

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

#define copy_to_area(x) \
({ \
memcpy(area->area + ((x) * (chunk_size + sizeof(uint_least32_t))), ptr, chunk_size); \

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
if(unlikely(new_buffer == NULL))
return NULL;

memcpy(new_buffer, ptr, min(req_size, (1U << m_area->chk_size_exp) - sizeof(uint_least32_t)));

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
src/mm/dymelor/checkpoint.c Fixed Show fixed Hide fixed
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Cppcheck (reported by Codacy) found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

Now it is possible to select between DyMeLoR and the buddy-based memory
allocator with a value in the config struct

Criticism and suggestions are always welcome!

Signed-off-by: Andrea Piccione <piccione@diag.uniroma1.it>
@github-actions
Copy link

github-actions bot commented Oct 6, 2022

Documentation coverage is 65.3% 👍

Classes    : 100.0% (1/1)
Defines    :  70.9% (107/151)
Enum Values:  68.1% (47/69)
Enums      :  41.7% (5/12)
Files      :  85.5% (65/76)
Functions  :  64.0% (256/400)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (3/3)
Structs    :  81.5% (22/27)
Typedefs   :  91.7% (11/12)
Variables  :  54.1% (118/218)
-----------------------------------
Total      :  65.3% (635/972)

Criticism and suggestions are always welcome!

Signed-off-by: Andrea Piccione <piccione@diag.uniroma1.it>
Criticism and suggestions are always welcome!

Signed-off-by: Andrea Piccione <piccione@diag.uniroma1.it>
@github-actions
Copy link

Documentation coverage is 65.6% 👍

Classes    : 100.0% (1/1)
Defines    :  70.9% (107/151)
Enum Values:  68.1% (47/69)
Enums      :  41.7% (5/12)
Files      :  89.5% (68/76)
Functions  :  64.0% (256/400)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (3/3)
Structs    :  81.5% (22/27)
Typedefs   :  91.7% (11/12)
Variables  :  54.1% (118/218)
-----------------------------------
Total      :  65.6% (638/972)

Fixed some checkpoint-restore edge cases  where we didn't properly cleanup
all DyMeLoR areas. The used_mem field is now properly checkpointed and
restored as well.

Criticism and suggestions are always welcome!

Signed-off-by: Andrea Piccione <piccione@diag.uniroma1.it>
@github-actions
Copy link

Documentation coverage is 65.6% 👍

Classes    : 100.0% (1/1)
Defines    :  70.9% (107/151)
Enum Values:  68.1% (47/69)
Enums      :  41.7% (5/12)
Files      :  89.5% (68/76)
Functions  :  63.7% (256/402)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (3/3)
Structs    :  81.5% (22/27)
Typedefs   :  91.7% (11/12)
Variables  :  54.4% (118/217)
-----------------------------------
Total      :  65.6% (638/973)

struct dymelor_area *area = *next_area_p;
area->alloc_chunks = ckpt->chunk_cnt;
size_t bitmap_size = bitmap_required_size(num_chunks);
memcpy(area->use_bitmap, ckpt->data, bitmap_size);

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
do {
area->alloc_chunks = ckpt->chunk_cnt;
size_t bitmap_size = bitmap_required_size(num_chunks);
memcpy(area->use_bitmap, ckpt->data, bitmap_size);

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
ckpt->i = i;
ckpt->chunk_cnt = area->alloc_chunks;
size_t bitmap_size = bitmap_required_size(num_chunks);
memcpy(ckpt->data, area->use_bitmap, bitmap_size);

Check notice

Code scanning / Flawfinder (reported by Codacy)

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.

Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data.
@github-actions
Copy link

Documentation coverage is 65.9% 👍

Classes    : 100.0% (1/1)
Defines    :  74.0% (108/146)
Enum Values:  68.1% (47/69)
Enums      :  41.7% (5/12)
Files      :  89.7% (70/78)
Functions  :  63.4% (255/402)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (2/2)
Structs    :  81.5% (22/27)
Typedefs   : 100.0% (11/11)
Variables  :  54.1% (118/218)
-----------------------------------
Total      :  65.9% (639/969)

@github-actions
Copy link

Documentation coverage is 66.1% 👍

Classes    : 100.0% (1/1)
Defines    :  73.2% (109/149)
Enum Values:  68.1% (47/69)
Enums      :  41.7% (5/12)
Files      :  89.3% (67/75)
Functions  :  64.2% (248/386)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (1/1)
Structs    :  80.8% (21/26)
Typedefs   : 100.0% (11/11)
Variables  :  54.7% (122/223)
-----------------------------------
Total      :  66.1% (632/956)

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