Skip to content

Conversation

@vinser52
Copy link

@vinser52 vinser52 commented Oct 7, 2022

This change is Reviewable

@vinser52 vinser52 requested review from byrnedj and igchor October 7, 2022 16:05
Copy link

@igchor igchor left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @byrnedj and @vinser52)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 128 at r1 (raw file):

  }

  void testMultiTiersRemoveDuringEviction() {

nit: you could probably make a generic function which would accept std::function F as a param and call F inside moveCB instead of copy-pasting the initialization phase.


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 150 at r1 (raw file):

      t = std::make_unique<std::thread>([&](){ alloc->remove(key); });
      // sleep to make sure async thread calls remove(key)
      std::this_thread::sleep_for(std::chrono::milliseconds(100));

nit: instead of this sleep you could probably use latches quite easily to make this deterministic: https://github.com/facebook/folly/blob/main/folly/synchronization/Latch.h


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 200 at r1 (raw file):

            });
        // sleep to make sure async thread calls remove(key)
        std::this_thread::sleep_for(std::chrono::milliseconds(100));

nit: similarly as above + comment is wrong (should be insertOrReplace)

Copy link
Author

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, all discussions resolved (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 128 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

nit: you could probably make a generic function which would accept std::function F as a param and call F inside moveCB instead of copy-pasting the initialization phase.

Done


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 150 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

nit: instead of this sleep you could probably use latches quite easily to make this deterministic: https://github.com/facebook/folly/blob/main/folly/synchronization/Latch.h

Done


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 200 at r1 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

nit: similarly as above + comment is wrong (should be insertOrReplace)

Done

Copy link

@igchor igchor left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @byrnedj and @vinser52)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 171 at r2 (raw file):

      auto key = oldItem.getKey();
      t = std::make_unique<std::thread>([&](){
            latch.count_down();

shouldnt this be after the remove? or are you trying to interleave the execution of remove with memcpy?
if this you just want to execute the remove and wait for completion then you could probably even just call join immediately, right?

Copy link
Author

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 171 at r2 (raw file):

Previously, igchor (Igor Chorążewicz) wrote…

shouldnt this be after the remove? or are you trying to interleave the execution of remove with memcpy?
if this you just want to execute the remove and wait for completion then you could probably even just call join immediately, right?

Remove call is blocked (on wait context) till async move is completed. So that we cannot call latch.count_down() after remove because it will cause deadlock.

Copy link
Author

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 171 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

Remove call is blocked (on wait context) till async move is completed. So that we cannot call latch.count_down() after remove because it will cause deadlock.

I understand that ideally latch.count_down() should be called when the thread hanged on the wait context, but it is not possible to implement in the test.

Copy link
Author

@vinser52 vinser52 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @byrnedj and @igchor)


cachelib/allocator/tests/AllocatorMemoryTiersTest.h line 171 at r2 (raw file):

Previously, vinser52 (Sergei Vinogradov) wrote…

I understand that ideally latch.count_down() should be called when the thread hanged on the wait context, but it is not possible to implement in the test.

I have added comments as we discussed in the chat

@vinser52 vinser52 merged commit 1a9525b into intel:develop Oct 11, 2022
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