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

Community detection memory tracking #431

Merged
merged 24 commits into from Feb 20, 2024
Merged

Conversation

imilinovic
Copy link
Collaborator

@imilinovic imilinovic commented Dec 10, 2023

Description

Community detection memory tracking was not working properly when multiple threads were used so it was fixed.

Add thread memory tracking to community detection.

Requires PR436 and PR1631 before merging

Note to reviewer (!!!):
Review with suffix ?w=1 to ignore whitespaces changes which are automatically made by IDE (and there are a lot of them).
Link for reviewing

Pull request type

  • Bugfix
  • Algorithm/Module
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Release note:

Community detection now respects memory limits and doesn't crash database.

Related issues

closes #379
closes #219
closes memgraph/memgraph#955

######################################

Reviewer checklist (the reviewer checks this part)

Module/Algorithm

######################################

@imilinovic imilinovic changed the title Community detection limits Community detection memory tracking Dec 10, 2023
@imilinovic imilinovic self-assigned this Dec 11, 2023
@imilinovic imilinovic added Docs unnecessary Docs unnecessary type: bug Something isn't working labels Dec 11, 2023
@gitbuda
Copy link
Member

gitbuda commented Dec 29, 2023

@imilinovic, quick question, what's the issue related? Can you link it? 👀

@imilinovic imilinovic marked this pull request as ready for review January 15, 2024 22:44
@imilinovic imilinovic added status: ready PR is ready for review Docs - changelog only Docs - changelog only and removed Docs unnecessary Docs unnecessary labels Jan 15, 2024
Comment on lines -15 to -28
# Module tests
if (NOT MAGE_CUGRAPH_ENABLE)
include(GoogleTest)
set(community_detection_test_src
community_detection_test.cpp
algorithm/louvain.cpp)

add_executable(community_detection_test "${community_detection_test_src}")
target_include_directories(community_detection_test PRIVATE ${GRAPPOLO_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(community_detection_test PRIVATE mg_utility basic_cd full_syn_opt coloring util OpenMP::OpenMP_CXX mage_gtest)
gtest_add_tests(TARGET community_detection_test)
endif()


Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests were ported to e2e tests.
The tests were not usable because now community_detection library uses mgp_graph and the graph testing library doesn't use that.

@imilinovic imilinovic marked this pull request as draft January 16, 2024 13:13
@imilinovic imilinovic marked this pull request as ready for review January 17, 2024 11:58
@imilinovic imilinovic marked this pull request as draft January 17, 2024 12:03
@imilinovic imilinovic marked this pull request as ready for review January 17, 2024 13:00
Copy link

@DavIvek DavIvek left a comment

Choose a reason for hiding this comment

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

Looks good to me. Only a small note.
As I understand the tests you moved to e2e are tests that existed before and passed, even though community detection algorithms weren't usable.
It would be good to add test that will check if the memory limit is being respected with introduced changes.

Copy link
Collaborator

@antepusic antepusic left a comment

Choose a reason for hiding this comment

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

Good job (& thanks for the reviewers’ note)!

I agree with @DavIvek that it would be good to have a test to verify that this query module now respects the memory limits. Also double-check if there remain any (de)allocations that aren’t tracked.

NB: Is it possible to disable SonarCloud warnings for this PR alone? While it’s a useful tool, its recommendations aren’t exactly relevant to this PR:

  • repeated code: this PR mainly consists of adding memory tracking calls
  • cognitive complexity of functions: not applicable here because all code save for the memory tracking calls is third-party

Copy link

sonarcloud bot commented Feb 19, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
21.8% Duplication on New Code (required ≤ 3%)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

@imilinovic
Copy link
Collaborator Author

imilinovic commented Feb 19, 2024

I think the test to check that this works can't be done because of the following:

Memory limit is always being respected but the problem was that memory counting was wrong. The only way would be to compare it with the system memory (or see if the system crashes when setting the limit close to available RAM on the machine) which I don't think is possible at least not with the current MAGE testing infrastructure.
@antepusic @DavIvek

I think sonarcloud can just be ignored here and merge if all other tests pass.

Copy link
Collaborator

@antepusic antepusic left a comment

Choose a reason for hiding this comment

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

Approved, thanks for the clarification about testing!

@imilinovic imilinovic merged commit d10612d into main Feb 20, 2024
8 of 9 checks passed
@imilinovic imilinovic deleted the community-detection-limits branch February 20, 2024 09:54
@imilinovic imilinovic modified the milestones: 1.16.0, 1.15.0 Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs - changelog only Docs - changelog only status: ready PR is ready for review type: bug Something isn't working
Projects
4 participants