Skip to content

Improve code base quality - #117

Merged
alessandropellegrini merged 16 commits into
developfrom
code-cleanup
Jun 25, 2025
Merged

Improve code base quality#117
alessandropellegrini merged 16 commits into
developfrom
code-cleanup

Conversation

@alessandropellegrini

Copy link
Copy Markdown
Member

This PR attempts to fix minor nits in the code base. More importantly, I am trying to improve the overall documentation coverage.

We still had some __thread storage class specifier in the code base.
Change it to the standard _Thread_local.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
They are not improving any performance though.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
Align __typeof to __typeof__

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
Improve readability by using more readable variable names.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
Documenting several functions/datatypes with missing documentation,
and fixing some documentation errors.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
There was an old email address in the code of conduct.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@alessandropellegrini
alessandropellegrini changed the base branch from master to develop May 27, 2025 10:51
@codecov

codecov Bot commented May 27, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 86.13445% with 33 lines in your changes missing coverage. Please review.

Project coverage is 86.36%. Comparing base (3c2cdcf) to head (3985d96).
Report is 17 commits behind head on develop.

Files with missing lines Patch % Lines
src/mm/model_allocator.c 87.77% 10 Missing and 1 partial ⚠️
src/mm/checkpoint/incremental.c 11.11% 8 Missing ⚠️
src/distributed/mpi.c 33.33% 4 Missing ⚠️
src/lp/process.c 87.87% 4 Missing ⚠️
src/mm/checkpoint/full.c 93.10% 1 Missing and 1 partial ⚠️
test/datatypes/bitmap.c 66.66% 2 Missing ⚠️
test/log/stats.c 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #117      +/-   ##
===========================================
+ Coverage    84.35%   86.36%   +2.00%     
===========================================
  Files           43       45       +2     
  Lines         1726     1569     -157     
  Branches        54       41      -13     
===========================================
- Hits          1456     1355     -101     
+ Misses         250      197      -53     
+ Partials        20       17       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Documentation coverage is 92.5% 👍

Classes    : 100.0% (1/1)
Defines    :  92.3% (120/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (60/64)
Functions  :  92.7% (265/286)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  92.5% (664/718)

@github-actions

Copy link
Copy Markdown

Documentation coverage is 92.5% 👍

Classes    : 100.0% (1/1)
Defines    :  92.3% (120/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (60/64)
Functions  :  92.7% (265/286)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  92.5% (664/718)

Documenting several functions/datatypes with missing documentation,
and fixing some documentation errors.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.6% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  90.8% (59/65)
Functions  :  98.3% (282/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.6% (681/720)

This commit moves around functions and data structures, based on the
following core ideas:

- Buddy system stuff are confined in mm/buddy/ files
- model_allocator.c should implement everything that can be seen by
  the model or pertains to the LP state memory. It interacts with
  the buddy system, so the concept of "multi.c" is not necessary, nor
  pertains to mm/buddy/. Out of mm/ no one should explicitly see
  the buddy system.
- in mm/checkpoint we have everything that relates to checkpointing of
  the LP state. So we now have an `autonomic.c` unit, a `full.c` unit,
  and an `incremental.c` unit, that is currently only keeping old code.
  `mm/checkpoint/checkpoint.h` is the only header exposing all
  checkpointing-related stuff, so independently of what you need
  (autonomic/full/incremental), you can include this header.

I am convinced this refactor helps people go and find stuff based on
the organization of the tree. There could be a minimal penaly, as we
have lost one `static inline` for a function, but I am happy
tolerating a minimal performance penalty in favor of readability.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.9% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (61/65)
Functions  :  98.3% (282/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.9% (683/720)

Ensure that all files are adhering to the ROOT-Sim code formatting
style.
There are some exceptions that have been discussed in the past, that
I am keeping as is as they are more readable.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.6% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (61/65)
Functions  :  97.6% (280/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.6% (681/720)

In the mm refactor, a renamed function was not renamed in the
corresponding header.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.9% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (61/65)
Functions  :  98.3% (282/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.9% (683/720)

This is dumb, because _we_ manage the actions, but yes, our code is
waaaay more secure now.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.9% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (61/65)
Functions  :  98.3% (282/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.9% (683/720)

@alessandropellegrini
alessandropellegrini marked this pull request as ready for review May 29, 2025 17:24
Comment thread src/mm/buddy/buddy.c Outdated
Comment thread src/mm/buddy/checkpoint.c Outdated
Comment thread src/lp/process.c Outdated
Comment thread src/mm/model_allocator.c Outdated

@Piccions Piccions left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good changes, left a couple of comments.
Only thing I am doubtful of is const qualification of local variables, but it's not a deal breaker for me

In stdlib there is the deprecated index(3) function which has been
deprecated in favour of strchr(3). Avoid using index as the name
of the variable to avoid any possible issues.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
Fix wrong documentation.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
I confused by mistake the message processing data with an LP context.
This is fixed, and the arguments names are made consistent in the
code base.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
This is made to align to the project conventions.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 94.9% 👍

Classes    : 100.0% (1/1)
Defines    :  93.1% (121/130)
Enum Values:  88.9% (48/54)
Enums      :  90.0% (9/10)
Files      :  93.8% (61/65)
Functions  :  98.3% (282/287)
Namespaces : 100.0% (3/3)
Pages      : 100.0% (1/1)
Structs    : 100.0% (17/17)
Typedefs   : 100.0% (11/11)
Variables  :  91.5% (129/141)
-----------------------------------
Total      :  94.9% (683/720)

@alessandropellegrini

Copy link
Copy Markdown
Member Author

I have fixed all your suggestions, thanks!

Regarding the consts, I agree it's not a game changer. I introduced that just to clarify to the reader that the variables are just temporaries that won't be updated.

@alessandropellegrini
alessandropellegrini merged commit 3dd9b9a into develop Jun 25, 2025
22 of 23 checks passed
@alessandropellegrini
alessandropellegrini deleted the code-cleanup branch June 25, 2025 13:24
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.

2 participants