-
Notifications
You must be signed in to change notification settings - Fork 15
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
Merge regions overhaul #201
Conversation
@KubaSz I added you as a reviewer given that you looked at the previous snapshot stuff, but feel free to ignore if you don't have scope to keep checking this stuff 😄 |
I don't have much time to review this, but from a quick glance I can offer two quick comments:
|
Ok nice, cheers and have a good Xmas! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just pointed out two very minor issues, feel free to ignore them.
I have deliberately marked all occurings I have found to aid in the re-factor if you end up going for it.
}; | ||
|
||
template<typename T> | ||
inline bool calculateDiffValue(const uint8_t* original, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediate to tell the difference between calculateDiffValue
and applyDiffValue
, could we add a comment explaining what each one does, or how they differ?
Also, just to double check, can the uint8_t
pointers here can't be converted to std::span
s?
@@ -25,6 +25,8 @@ void FaabricMain::startBackground() | |||
// Crash handler | |||
faabric::util::setUpCrashHandler(); | |||
|
|||
PROF_BEGIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point made in the Faasm PR re. comitting profiling macros. I would personally remove them, but feel free to ignore.
|
||
#include <sys/mman.h> | ||
|
||
namespace faabric::snapshot { | ||
std::shared_ptr<faabric::util::SnapshotData> SnapshotRegistry::getSnapshot( | ||
const std::string& key) | ||
{ | ||
PROF_START(GetSnapshot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point re. profiling (feel free to ignore).
{ | ||
static ClearRefsWrapper wrap; | ||
|
||
PROF_START(ResetDirty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here re. profiling (feel free to ignore).
{ | ||
// Note we only need a shared lock here as we are not modifying data and the | ||
// OS will handle synchronisation of the mapping itself | ||
PROF_START(MapSnapshot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point re. profiling
@@ -337,6 +400,7 @@ MemoryView::MemoryView(std::span<const uint8_t> dataIn) | |||
|
|||
std::vector<SnapshotDiff> MemoryView::getDirtyRegions() | |||
{ | |||
PROF_START(GetDirtyRegions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Profiling
@@ -36,9 +36,13 @@ TEST_CASE_METHOD(SnapshotTestFixture, | |||
|
|||
int sharedMemPages = 8; | |||
size_t sharedMemSize = sharedMemPages * HOST_PAGE_SIZE; | |||
MemoryRegion sharedMem = allocateSharedMemory(sharedMemSize); | |||
MemoryRegion sharedMem = allocatePrivateMemory(sharedMemSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to double check, the variable is called sharedMem
and is defined by calling allocatePrivateMemory
which feels odd.
@@ -433,7 +433,7 @@ TEST_CASE("Test mapping memory", "[util]") | |||
TEST_CASE("Test mapping memory fails with invalid fd", "[util]") | |||
{ | |||
size_t memSize = 10 * HOST_PAGE_SIZE; | |||
MemoryRegion sharedMem = allocateSharedMemory(memSize); | |||
MemoryRegion sharedMem = allocatePrivateMemory(memSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point re. variable wording.
@@ -179,12 +179,12 @@ TEST_CASE_METHOD(SnapshotMergeTestFixture, | |||
std::vector<uint8_t> expectedSnapMem = snap->getDataCopy(); | |||
|
|||
// Set up two shared mem regions | |||
MemoryRegion sharedMemA = allocateSharedMemory(snapSize); | |||
MemoryRegion sharedMemB = allocateSharedMemory(snapSize); | |||
MemoryRegion sharedMemA = allocatePrivateMemory(snapSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point re. variable naming throughout this test.
@@ -590,6 +592,214 @@ TEST_CASE_METHOD(SnapshotMergeTestFixture, | |||
expectedData = faabric::util::valueToBytes<int>(diffValue); | |||
} | |||
|
|||
SECTION("Long") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice nesting of tests here 👍
I'll merge this in the interest of moving things along and fixing downstream, then I'll put the refactoring into #210 |
This PR addresses the following problems:
Raw
andInt
types (needed more types includingBool
,Long
,Float
andDouble
).When it comes to transferring merge regions across hosts, we have to consider three scenarios where snapshot data is being transferred:
In the first two, we are not currently including merge regions, which means, if the main thread on the main host sets up some merge regions, they are not respected by remote hosts.
Changes:
Ignore
merge regions to blacklist regions of memory (e.g. guard pages), then automatically fill the rest of the snapshot memory withOverwrite
regions.