-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
pXXXX - Fallible Allocators for Algorithms #14
Comments
Despite people telling me it exists, I cannot find the overloads of Alexander Stepanov's STL algorithms with anything like a |
Don't forget that if you provide pre-allocated buffers, people will ask to support allocators too. It is tightly linked to |
Some insight: MSVC's STL already has a basically-allocator plus optimistic-stack-allocation internals for this. We'd likely just be standardizing an existing library practice: need to look at |
IIRC both libc++ and libstdc++ rely on global Also related: Stepanov mentioned long ago that There could be ways to optimize
|
In the previous comment I started to mention regrowth for As a practical example to discuss further, here is my auto try_grow(std::ptrdiff_t count) noexcept
-> bool
{
auto tmp = get_temporary_buffer<T>(count, buffer_size);
if (not tmp.first) {
// If the allocated buffer isn't bigger, keep the old one
return_temporary_buffer<T>(tmp.first, tmp.second);
return false;
}
// If the allocated buffer is big enough, replace the previous one
return_temporary_buffer(buffer, buffer_size);
buffer = tmp.first;
buffer_size = tmp.second;
return true;
} Most of my algorithms - just like those you are trying to improve - don't actually need a buffer at all to work, but the bigger the buffer, the simpler the algorithm and the faster it should run. This function answers to those specific needs by performing the following operation: it tries to grow the buffer up to a given size, and doesn't allocate anything if it can't. In order to fo this, If better low-level memory allocation functions were provided, then we could most likely improve upon the status quo:
Also it's worth noting that it's really all about allocating and deallocating memory. There is an implicit contract that when the destructor or It's a bit unstructured, but you now have my thoughts and ruminations about the use cases, potential optimization and assumptions about a potential |
Concerning N1085, here is an answer by Howard himself:
On the positive side it means that such memory allocation proposals weren't shot down because of implementability concerns or design issues, but purely out of lack of interest. |
And I found the
Interestingly enough the way I use the assumption that I mentioned a few comments ago - about not having to copy/move objects and just reallocating storage - might apparently be a good use case for I think that I'm done commenting and throwing ideas and remarks for now. Sorry for the spam ^^' |
Nothing so educational could ever be labeled with a word like "spam". |
I updated my cpp-sort library to take advantage of what I mentioned in my big comment, and restructured said comment a bit to make it clearer and less redundant :) |
This issue has been subsumed by the need for a fallible allocator, which is separate from a "more complete" allocator (though should receive the same improvements). |
Depends on #34/p2256. |
Why not use a verb? The ranges name spaces is full of them, so why not also Bonus: |
I could try that. I haven't come across any name that really helps. Right now it's not too important, though, because one of the things I'm realizing is that this is going to have to coexist with the initial allocator's infrastructure anyways. Might as well just make all the function names be different and let the existence of said functions be the detection mechanism on any given |
std::scratch_space
is a type that is meant to be passed to algorithms which currently internally and opaquely allocate to gain their complexity guarantees. Three such algorithms in the standard are known:std::stable_sort
std::stable_partition
std::inplace_merge
For -ffreestanding and similar, we should provide overloads which take this scratch space bucket and work solely within it, to avoid paying the cost of opaque dynamic allocations inside of the algorithms.
The text was updated successfully, but these errors were encountered: