-
Notifications
You must be signed in to change notification settings - Fork 6
perf(graph-db): stream the sealed store build one column at a time #2282
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
Merged
Merged
Changes from all commits
Commits
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| //! Per-thread allocation accounting for the lib test binary. | ||
| //! | ||
| //! Tests run concurrently in one process, so a process-wide counter would | ||
| //! charge one test for another's allocations. Each thread counts its own | ||
| //! live bytes instead; a measurement is only meaningful for work that runs | ||
| //! entirely on the measuring thread. | ||
|
|
||
| use std::alloc::{GlobalAlloc, Layout, System}; | ||
| use std::cell::Cell; | ||
|
|
||
| thread_local! { | ||
| static LIVE: Cell<isize> = const { Cell::new(0) }; | ||
| static PEAK: Cell<isize> = const { Cell::new(0) }; | ||
| } | ||
|
|
||
| struct ThreadCountingAllocator; | ||
|
|
||
| fn charge(bytes: isize) { | ||
| let _ = LIVE.try_with(|live| { | ||
| let now = live.get() + bytes; | ||
| live.set(now); | ||
| let _ = PEAK.try_with(|peak| peak.set(peak.get().max(now))); | ||
| }); | ||
| } | ||
|
|
||
| // SAFETY: every call delegates to `System` with the caller's layout; the | ||
| // accounting touches only const-initialized thread-locals, which never | ||
| // allocate. | ||
| unsafe impl GlobalAlloc for ThreadCountingAllocator { | ||
| unsafe fn alloc(&self, layout: Layout) -> *mut u8 { | ||
| // SAFETY: forwarded unchanged. | ||
| let pointer = unsafe { System.alloc(layout) }; | ||
| if !pointer.is_null() { | ||
| charge(layout.size().cast_signed()); | ||
| } | ||
| pointer | ||
| } | ||
|
|
||
| unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { | ||
| // SAFETY: forwarded unchanged. | ||
| let pointer = unsafe { System.alloc_zeroed(layout) }; | ||
| if !pointer.is_null() { | ||
| charge(layout.size().cast_signed()); | ||
| } | ||
| pointer | ||
| } | ||
|
|
||
| unsafe fn dealloc(&self, pointer: *mut u8, layout: Layout) { | ||
| // SAFETY: forwarded unchanged. | ||
| unsafe { System.dealloc(pointer, layout) }; | ||
| charge(-layout.size().cast_signed()); | ||
| } | ||
|
|
||
| unsafe fn realloc(&self, pointer: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { | ||
| // SAFETY: forwarded unchanged. | ||
| let resized = unsafe { System.realloc(pointer, layout, new_size) }; | ||
| if !resized.is_null() { | ||
| charge(new_size.cast_signed() - layout.size().cast_signed()); | ||
| } | ||
| resized | ||
| } | ||
| } | ||
|
|
||
| #[global_allocator] | ||
| static ALLOCATOR: ThreadCountingAllocator = ThreadCountingAllocator; | ||
|
|
||
| /// Runs `work` and returns its result with the most bytes this thread held | ||
| /// above what it held when `work` started. | ||
| pub(crate) fn peak_above_start<R>(work: impl FnOnce() -> R) -> (R, usize) { | ||
| let start = LIVE.with(Cell::get); | ||
| PEAK.with(|peak| peak.set(start)); | ||
| let result = work(); | ||
| let peak = PEAK.with(Cell::get) - start; | ||
| (result, usize::try_from(peak).unwrap_or(0)) | ||
| } |
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.
Every successful graph-db unit-test run executes this ad hoc diagnostic, even though the assertion immediately below already reports the measured peak when the budget fails. Remove it rather than merging investigative stderr scaffolding, as the repository requires Hotpath/tracing for maintained observability and explicitly prohibits merged
eprintln!scaffolds.AGENTS.md reference: AGENTS.md:L151-L160
Useful? React with 👍 / 👎.