-
Couldn't load subscription status.
- Fork 44
Implement new snapshotting system with support for elastic memory growth via mmap()
#277
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
Closed
Closed
Changes from all commits
Commits
Show all changes
195 commits
Select commit
Hold shift + click to select a range
16e0570
Sketch out interface
mcevoypeter 9fa2538
Add clang-format configuration
mcevoypeter d590931
Stub out functions
mcevoypeter c01e091
Build library
mcevoypeter e934648
Add parameter for base address to pma_init()
mcevoypeter d505257
Implement pma_init()
mcevoypeter 74c2f4e
Remove leading and trailing spaces from conditionals
mcevoypeter 4f62939
Expose PMA length as parameter in pma_init()
mcevoypeter 9539978
Implement map_file_()
mcevoypeter dd529bc
Add mapped heap and stack len fields to pma_t
mcevoypeter b6036cd
Implement pma_deinit()
mcevoypeter d3b5b2c
Test pma_init()
mcevoypeter 64eda97
Install dummy page fault handler
mcevoypeter 1599817
Allocate memory in page fault handler via mmap()
mcevoypeter 414c1d9
Switch from MAP_SHARED to MAP_PRIVATE
mcevoypeter c9b1fe6
Add array to pma_t for tracking dirty pages
mcevoypeter 9e9171b
Implement addr_to_page_idx_()
mcevoypeter ff7a677
Add ability to test static PMA functions
mcevoypeter b1029fd
Test addr_to_page_idx_()
mcevoypeter b7884c3
Test round_up_()
mcevoypeter 199c65c
Always fail in pma_init() if HAVE_SIGSEGV_RECOVERY isn't defined
mcevoypeter 1f358b5
Only handle SIGSEGV for PMA pages
mcevoypeter 8f27d69
Switch addr_to_page_idx_() to 0-based and remove negative indices
mcevoypeter 1a4ea49
Use two bits to track page status, not one
mcevoypeter 9cd793e
Use page_status_() in handle_page_fault_()
mcevoypeter 4bd36ec
Remove write protections from mapped page in page fault handler
mcevoypeter 9f993a9
Set page status in map_file_()
mcevoypeter 84078c5
Move rounding functions into separate file
mcevoypeter bc09978
Change return type of page_status_() to page_status_t
mcevoypeter 83c7e3f
Handle empty files correctly
mcevoypeter 6a41fc0
Replace u3e_live() with pma_init()
mcevoypeter d374162
Replace static with static_ for constants
mcevoypeter c903cee
Add set_page_status_range_()
mcevoypeter 780dd64
Make addr as const where possible
mcevoypeter 5631f16
Move kPageSz into separate header file
mcevoypeter 1ffcabc
Stub out journal interface
mcevoypeter c30eeae
Implement journal_open()
mcevoypeter 409647d
Add missing path to fprintf()
mcevoypeter 1e99a05
Run clang-format
mcevoypeter 3194118
Stub out read_all() and write_all()
mcevoypeter 44b7708
Implement read_all() and write_all()
mcevoypeter 977056e
Implement journal_append()
mcevoypeter 3670781
Add path to journal_t
mcevoypeter 4249bd0
Implement journal_destroy()
mcevoypeter b05ae5e
Implement journal_apply()
mcevoypeter 5e8ca10
Allow stack-allocated journal_t via journal_open()
mcevoypeter 119e372
Add crash recovery at end of pma_init() via pma_sync()
mcevoypeter 2524f4e
Sync heap and stack files using journal in pma_sync()
mcevoypeter 30bc597
Resize backing files and reapply mappings
mcevoypeter 7126f48
Don't explicitly extend backing files
mcevoypeter f8588a5
Add total_len_()
mcevoypeter 226333d
Use set_page_status_range_(
mcevoypeter af7e969
Add journal_sync()
mcevoypeter 42c43d9
fsync() backing file after applying journal
mcevoypeter 79bc3b3
Construct journal file path
mcevoypeter 12e12cd
Return 0 on success from write_all()
mcevoypeter 99c136a
Add new_file_() helper function to pma_tests
mcevoypeter 7a47180
Allow NULL path as argument to sync_file_()
mcevoypeter 4bda946
Add heap and stack file paths to pma_t
mcevoypeter 9606485
Pass correct base address for stack when calling write_all() in sync_…
mcevoypeter 5e081d4
Log error messages read_all() and write_all()
mcevoypeter 75811e4
Add pma_sync() to empty backing files test
mcevoypeter 2f8831d
Successfully test page status after read only
mcevoypeter 8f1249d
Modify new_file_() to support creating large files
mcevoypeter 88a2ac4
Add macros for dealing with GiB, MiB, and KiB
mcevoypeter d8e2eac
Unmap entire arena in pma_deinit()
mcevoypeter 4de5105
Test file-backed PMA with sync and truncation
mcevoypeter bb3f22b
Add PMA_DEBUG macro to make it possible to debug SIGSEGV
mcevoypeter b30488f
Replace u3e_save() with pma_sync()
mcevoypeter a871bc8
Comment out heap logic in pma_sync()
mcevoypeter bf317ed
Add missing return statement to journal_sync()
mcevoypeter e87ccc1
Reset pma heap_len and heap_fd after sync_file_()
mcevoypeter ad1c38f
End print statements with \r\n
mcevoypeter 6fda596
Apply journal directly to snapshot file
mcevoypeter 6105ca4
Lint
mcevoypeter 2a5a209
Correctly update stack len and heap and stack fd fields in pma_t
mcevoypeter 116d19b
Properly declare and define inline utility functions
mcevoypeter 85e70f0
Reformat separating banners
mcevoypeter ff579cc
Add --config=test to CI invocation of unit tests
mcevoypeter f147c3a
Rename pma_init() as pma_load()
mcevoypeter 4a2452b
Rename pma_deinit() as pma_unload()
mcevoypeter 6f6b563
Undef inline_
mcevoypeter 602d742
Document page_status_t and pma_t
mcevoypeter e1ddd11
More efficiently remove unused mappings in pma_sync()
mcevoypeter 81cf617
Document map_file_()
mcevoypeter a313471
Tweak handle_page_fault_() documentation
mcevoypeter 4ccaf34
Tweak addr_to_page_idx_() documentation
mcevoypeter 3e3bf00
Improve documentation for page status getter and setters
mcevoypeter 8b35580
Improve sync_file_() documentation
mcevoypeter ea1b1dd
Document kPageSz
mcevoypeter 907f4cf
Rename journal as wal (write-ahead log)
mcevoypeter 5d8413a
Document wal_t and wal_entry_t
mcevoypeter f9bbfaf
Document wal interface
mcevoypeter e6b7f18
Return error from pma_load() if stack and heap overlap
mcevoypeter 9fe978c
Document pma interface
mcevoypeter 4fd6249
Factor out duplicated snapshot logic
mcevoypeter 78ec3a0
Remove old snapshotting system
mcevoypeter 3f9c81e
Place guard page at end of pma_sync()
mcevoypeter 294cd40
Recenter guard page in fault handler
mcevoypeter da85a35
Revert "Recenter guard page in fault handler"
mcevoypeter 4321ab6
Add OOM handler to pma_load() interface
mcevoypeter 7d1af91
Bail meme from OOM handler
mcevoypeter 562201e
Correctly recenter guard page on OOM
mcevoypeter d56e249
Properly apply write-ahead log to snapshot during crash recovery
mcevoypeter 2fd2f12
Mark just-mapped pages as dirty, not clean
mcevoypeter 1254a98
Remove reundant wal_apply() in map_file_()
mcevoypeter 3f4a31e
Don't unmap at end of pma_sync()
mcevoypeter 1b0e547
Validate write-ahead log
mcevoypeter 92b4ef1
Replace %llu with %zu when printing size_t
mcevoypeter 14efdea
Properly handle unaligned base and len in pma_load()
mcevoypeter db28dec
Remove inappropriate assert()s in wal_destroy()
mcevoypeter 110b0da
Add basic error handling instructions
mcevoypeter 990f71f
Set errno correctly in read_all() and write_all()
mcevoypeter 5f611cb
Return success early from read_all() and write_all() for zero length
mcevoypeter 93317ca
Fold typedef into same line as struct declaration
mcevoypeter 10f20c6
Remove extra white space
mcevoypeter 4e2d53a
Document that kBitsPerByte must be power of 2
mcevoypeter dac9cec
Remove stale documentation restricting use of PS_MASK
mcevoypeter d099663
Remove stale wal_entry_t
mcevoypeter a1e6166
Rename u3m_take_snapshot() as u3m_save_snapshot()
mcevoypeter f406c87
Correct error handling in wal_open()
mcevoypeter 8da9bfb
Finish adding errno semantics
mcevoypeter e2c3798
Remove unnecessary declarations for inline arithmetic functions
mcevoypeter a6f9a35
Add PS_MAPPED_DIRTY to handle_page_fault_() switch statement
mcevoypeter 11dee5c
Directly include pma.c in pma_tests.c
mcevoypeter 732293a
Simplify PS_UNMAPPED assert
mcevoypeter 09c62b4
Remove leading . from file extensions
mcevoypeter 22922ba
Include page index in WAL checksum
mcevoypeter 728ea16
Test write-ahead log
mcevoypeter eae3739
Back up snapshot
mcevoypeter 3dda1a8
Use %lld for off_t, not %u
mcevoypeter 60af462
Add missing return to wal_apply()
mcevoypeter 0fb6f9c
Remove --config=test from CI unit test invocation
mcevoypeter 04f3a02
Expose pma_center_guard_page() in public interface
mcevoypeter 924fa18
Add global checksum to write-ahead log
mcevoypeter 964dbf0
madvise() when heap or stack shrinks in pma_sync()
mcevoypeter 9687351
Clarify documentation of kBitsPerPage
mcevoypeter be9e0ed
Revert "Remove unnecessary declarations for inline arithmetic functions"
mcevoypeter 35d4bae
Source kPageSz from page.h in util tests
mcevoypeter 6001287
Switch to 64KB pages
mcevoypeter 9ef007a
Remove fragile round_up() test case
mcevoypeter 44bf4be
Switch to 128KB pages
mcevoypeter 4a22a78
Remove unnecessary trailing _ from variable names
mcevoypeter fd6d6cc
Use leading, not trailing, underscore for statically-scoped identifiers
mcevoypeter fd9700d
Rename pma_center_guard_page() as pma_adjust()
mcevoypeter a7aab03
Document PMA interface
mcevoypeter 88cf858
Document PMA implementation
mcevoypeter 9899773
Remove pma->max_sz
mcevoypeter fdac132
Update wal.h header guards
mcevoypeter 044b198
Document WAL interface and implementation
mcevoypeter 0876513
Use u3m_backup_snapshot() to back up snapshot
mcevoypeter 8b16de5
Define NDEBUG on release builds
mcevoypeter ce5501d
Revert "Define NDEBUG on release builds"
mcevoypeter 4b2bca5
Free pma in pma_unload()
mcevoypeter cb8544b
Verify len in _sync_file() is multiple of kPageSz
mcevoypeter b104999
Make explicit WAL usage pattern
mcevoypeter b3aab95
Mark pages as unmapped on failure in _map_file()
mcevoypeter 3717c4c
Revert "Switch to 128KB pages"
mcevoypeter 0c32314
Pass fd to _map_file() instead of path
mcevoypeter 8c40f6f
Apply write-ahead log in pma_load(), not _map_file()
mcevoypeter d99a148
Use one WAL for both heap and stack
mcevoypeter 144f599
Give wal_open() a directory path, not a file path
mcevoypeter a9d7ed3
Use fnctl(F_FULLFSYNC) on macOS
mcevoypeter 8e8e64c
Don't truncate backing files
mcevoypeter d7da1ec
Don't create anonymous mappings when the backing file is nonexistent
mcevoypeter cb10b17
Remove unused fd parameter to _append_dirty_pages()
mcevoypeter 767fc64
Replace "is there" with "if there" in pma_t documentation
mcevoypeter 35aff84
Add @param[in] documentation for oom_handler_t's fault_addr
mcevoypeter e955a08
Fix argument offsets in pma_load() call
mcevoypeter b30ba3c
Remove extra space in fprintf()
mcevoypeter beab2d9
Remove now-unnecessary pma_adjust() parameter comments
mcevoypeter 9601b32
Explain that i is unused because of read_all() semantics
mcevoypeter cfc5c26
Clarify failure comments at _map_file() call sites
mcevoypeter 5a246f8
Clarify comment in _map_file() about anonymous mappings
mcevoypeter 4ac859c
Replace int with c3_o in new u3m signatures
mcevoypeter 1505ad8
Remove unused variable in PMA tests
mcevoypeter 779881f
Revert "Switch to 64KB pages"
mcevoypeter 930e4e4
Require stack and heap files to be both NULL or both non-NULL
mcevoypeter 3e15ad1
Add retry logic to write_all()
mcevoypeter 822c391
Add retry logic to read_all()
mcevoypeter b9676d4
Replace assert() with c3_assert()
mcevoypeter 45285e0
Initialize tmp checksum variable to 0
mcevoypeter d393848
Lint
mcevoypeter a2d30db
Ensure global checksum integrity at end of wal_open()
mcevoypeter 4902621
Add test for corrupt WAL entry checksum
mcevoypeter c49c88c
Ensure all 64-bit values passed to MurmurHash3_x86_32 are zero-initia…
mcevoypeter c9eacfd
Read metadata header in wal_open()
mcevoypeter fd3927e
Include page index in checksum in wal_append()
mcevoypeter fd3aacb
Add _page_checksum()
mcevoypeter 2042bb5
Add WAL version number
mcevoypeter 3d2326c
Replace mistaken use of data_path with meta_path
mcevoypeter 80bc6d2
Revert "Don't unmap at end of pma_sync()"
mcevoypeter bb556f7
Mark untracked dirty pages as read-only at end of pma_sync()
mcevoypeter d0083d1
Reserve entire PMA in pma_load()
mcevoypeter 6ac58b3
Address review feedback, MADV_DONTNEED ephemeral space
philipcmonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ cc_library( | |
| deps = [ | ||
| "//pkg/c3", | ||
| "//pkg/ent", | ||
| "//pkg/pma", | ||
| "//pkg/ur", | ||
| "//pkg/urcrypt", | ||
| "@gmp", | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is no mention of a debug assert here, i.e.
c3_dessert. Especially in hotpaths, extra conditional jumps almost certainly hurt performance rather than improve the compiler's optimization capability.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.
Thanks for pointing this out. To address this, I've defined
NDEBUGfor release builds, which will replaceassert()with(void)(0).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.
Had to revert the
NDEBUGdefinition because it's leading to segfaults, potentially related to our current abuse ofc3_assert().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.
Yeah I expected that. But also, there's an important difference between
c3_dessertandassert. dessert actually allows you to recover an assertion if you have a debugger attached. If you don't, the process will dump core. But if you do, it's effectively a conditional breakpoint in your code. There are some scenarios where that's usefulThere 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.
I'm reluctant to introduce
c3as dependency ofpma.uris also implemented as a separate library that doesn't depend onc3, so there's a precedent. To your point about wanting the utility functions defined in a shared place, I wonder if it makes sense to define a separateutilitypackage that includes these sorts of things.c3is partially that but also partially a statement of opinion on how to use C due to its inclusion of loobeans, typedefs, etc.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.
+1 to a separate
utilitypackage