-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dirty tracking performance improvements (#210)
* Start on userfault experiment * Tidy up * Failing test for mapped regions * Destroy uffd tests * Refactor to suit configurable diffing * Fixed tests for soft dirty PTEs * Snapshot self-dirty tracking * Working tests * Tidy up when executor does dirty tracking * Special-case reinitialisation * Remove restartTracking * Remove duplicated function names * Handle dirty regions * Move gap filling back again * Update to using OffsetMemoryRegions * Remove debug logging * Tidy up * Renaming * Missing comments * Add test for multi-threaded segfault handling * Remove dirty checks from memory test * Fixing up tests * Refactor overwrite diff logic * Fix test * Formatting * Add main thread snapshot handling to faabric * Incorporate size change into main thread snapshot * Simplify logic around snapshots in executor * Fixing a couple of tests * Fixing tests * Small tidy-ups * Fix up unit tests * Fix up a couple of distributed tests * Moved thread scheduling and decision caching into executor * Fixing dist tests * Remove core dump * Formatting * Revert trace logging in DC file * Fix data race in tests * Tidy up and docs * Formatting * Guard against empty memory * More logging * Specify merge regions when spawning threads * Small logging fix * Attempt to speed up diffing * Tighter diffing loops * Merge diffing and regions * Remove OffsetMemoryRegion * Avoid vector<bool> * More dirty tracking * Fix up SDPTE * Switch from shared to full lock * Add test for dirty tracking config field * Remove await thread results funciton
- Loading branch information
Showing
37 changed files
with
2,478 additions
and
1,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
|
||
namespace faabric::util { | ||
|
||
void setUpCrashHandler(); | ||
/* | ||
* Sets up crash handling. By default covers a number of signals that would | ||
* otherwise cause a crash. Signal argument can be provided to reinstating crash | ||
* handling for a specific signal after it's been used elsewhere in the | ||
* application (e.g. for dirty tracking). | ||
*/ | ||
void setUpCrashHandler(int sig = -1); | ||
|
||
/* | ||
* Prints the stack trace for a given signal. Only to be called in signal | ||
* handlers. | ||
*/ | ||
void handleCrash(int sig); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#pragma once | ||
|
||
#include <signal.h> | ||
#include <span> | ||
#include <string> | ||
|
||
#include <faabric/util/config.h> | ||
#include <faabric/util/logging.h> | ||
#include <faabric/util/memory.h> | ||
|
||
#define CLEAR_REFS "/proc/self/clear_refs" | ||
#define PAGEMAP "/proc/self/pagemap" | ||
|
||
#define PAGEMAP_ENTRY_BYTES sizeof(uint64_t) | ||
#define PAGEMAP_SOFT_DIRTY (1Ull << 55) | ||
|
||
namespace faabric::util { | ||
|
||
/* | ||
* Interface to all dirty page tracking. Implementation-specific boilerplate | ||
* held in subclasses. | ||
*/ | ||
class DirtyTracker | ||
{ | ||
public: | ||
virtual void clearAll() = 0; | ||
|
||
virtual void reinitialise() = 0; | ||
|
||
virtual void startTracking(std::span<uint8_t> region) = 0; | ||
|
||
virtual void stopTracking(std::span<uint8_t> region) = 0; | ||
|
||
virtual std::vector<std::pair<uint32_t, uint32_t>> getDirtyOffsets( | ||
std::span<uint8_t> region) = 0; | ||
|
||
virtual void startThreadLocalTracking(std::span<uint8_t> region) = 0; | ||
|
||
virtual void stopThreadLocalTracking(std::span<uint8_t> region) = 0; | ||
|
||
virtual std::vector<std::pair<uint32_t, uint32_t>> | ||
getThreadLocalDirtyOffsets(std::span<uint8_t> region) = 0; | ||
|
||
virtual std::vector<std::pair<uint32_t, uint32_t>> getBothDirtyOffsets( | ||
std::span<uint8_t> region) = 0; | ||
}; | ||
|
||
/* | ||
* Dirty tracking implementation using soft-dirty PTEs | ||
* https://www.kernel.org/doc/html/latest/admin-guide/mm/soft-dirty.html | ||
*/ | ||
class SoftPTEDirtyTracker final : public DirtyTracker | ||
{ | ||
public: | ||
SoftPTEDirtyTracker(); | ||
|
||
~SoftPTEDirtyTracker(); | ||
|
||
void clearAll() override; | ||
|
||
void reinitialise() override; | ||
|
||
void startTracking(std::span<uint8_t> region) override; | ||
|
||
void stopTracking(std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
void startThreadLocalTracking(std::span<uint8_t> region) override; | ||
|
||
void stopThreadLocalTracking(std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getThreadLocalDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getBothDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
private: | ||
FILE* clearRefsFile = nullptr; | ||
|
||
FILE* pagemapFile = nullptr; | ||
}; | ||
|
||
/* | ||
* Dirty tracking implementation using mprotect to make pages read-only and | ||
* use segfaults resulting from writes to mark them as dirty. | ||
*/ | ||
class SegfaultDirtyTracker final : public DirtyTracker | ||
{ | ||
public: | ||
SegfaultDirtyTracker(); | ||
|
||
void clearAll() override; | ||
|
||
void reinitialise() override; | ||
|
||
void startTracking(std::span<uint8_t> region) override; | ||
|
||
void stopTracking(std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
void startThreadLocalTracking(std::span<uint8_t> region) override; | ||
|
||
void stopThreadLocalTracking(std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getThreadLocalDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> getBothDirtyOffsets( | ||
std::span<uint8_t> region) override; | ||
|
||
// Signal handler for the resulting segfaults | ||
static void handler(int sig, siginfo_t* info, void* ucontext) noexcept; | ||
|
||
private: | ||
void setUpSignalHandler(); | ||
}; | ||
|
||
DirtyTracker& getDirtyTracker(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.