This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
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.
[DNM] Wrapper allocator PoC #7206
base: master
Are you sure you want to change the base?
[DNM] Wrapper allocator PoC #7206
Changes from 3 commits
d86bd79
998a6ff
dbd40a7
c8e9d1c
b841129
d3e3e72
089e6d8
818699a
052b096
66e8a8b
dbdeb52
1dfd9ca
152888f
70aed93
88c1a70
b137472
b810ce4
314e519
62b489f
14e6605
929e2d4
06ccdf2
aaea117
c7bbfba
08f4333
0f27b6c
e813323
12fdcba
0f57383
2dda590
730a1c8
04ae532
6f9fe26
ffb8d15
74b2fec
2a2393f
ed8f0f8
4f47d3c
d25f550
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Won't this will deadlock if
start_tracking
is called twice? (Assigning a newbacklog
will trigger a deallocation of the oldbacklog
.)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.
Seems like you're right 😕
Nah, the whole thing now seems FUBAR to me. I was thinking about using the nightly
allocator_api
feature andVec::with_capacity_in()
to allow side-allocations from the main allocator but everything I try to implement looks too hacky. I'll give a try to your spinlock approach, probably, the overhead will be even less than the overhead of allocating and initializing the 800 Mb array and then replaying it.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.
Btw, why didn't you use
std::hint::spin_loop()
insidewhile
in your spinlock example? Was it on purpose?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.
No particular reason; I wrote that code from memory and simply forgot. :P Yeah, you should probably add that. (On AMD64 that will generate a
pause
instruction, which is generally a good idea to use in a spinlock.)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.
Looking at your code a bit more... The critical section is under exclusive lock now, do
current
andpeek
still have to beAtomic
s? Would we cut off a bit of the overhead making them simpleisize
s?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.
AFAIK they don't. I just used them as I didn't feel like using an
UnsafeCell
for the example.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.
Repeating some things as my review yesterday got lost. The memory overhead per prepare job right now is too high to be viable, if we really do that many allocations. It is an interesting idea, but it does have the extra complexity of determining what is a safe amount to pre-allocate. Not sure if the latency spike at the end is a problem, we do it at the end of an already blocking operation, but ideally we benchmark the overall start-to-end time and get numbers for the different approaches. The panic can be worked around (just set some bit that we overflowed and return an error in
end_tracking
). Overall the spinlock strategy does seem like the best approach so far.