Date: Tue, 14 Jan 2025 21:14:28 +0000
Hi everyone, I had been playing around with things like “alloca”, and improving some algorithms that can have dynamic memory (within certain constraints)
and those improvements have worked quite well, with quite remarkable results precisely because of the speed of just leveraging the stack to do things.
But to my disappointment there’s very little in the way to leverage it adequately and make it more nimble to use.
So, my idea on this is that there should be a more structured way to dynamically mutate the size of a buffer on a stack.
At least some of its features would be:
* There should be a “stack buffer point” – A singular referenceable pointer that is accessible that indicates the start of the stack position where the dynamic buffer starts. Having multiple independent ones is not because of how a stack works.
* A facility that tells you how much stack is available and can be used – So that you don’t accidentally blow up the stack, and you can make an informed decision on either or not you want to allocate something on the stack or fallback to using the heap.
* A facility to resize how much of the stack is reserved – Which would allow you to decrease the amount of memory as well as increase it (right now we can only increase it with alloca).
Some constraints seem obvious, like functions that use dynamic stack can not be inlined by the compiler otherwise it could be ill formed.
But it has become quite clear to me that this task is a bit over my capabilities.
This is a call for help from people who might know more about how features like “alloca” works on different platforms, how compilers manage data on the stack, etc.
who would be willing to help and create a road map on how structured dynamic stack allocation should look like such that you can make it part of the standard.
Best regards,
Tiago
and those improvements have worked quite well, with quite remarkable results precisely because of the speed of just leveraging the stack to do things.
But to my disappointment there’s very little in the way to leverage it adequately and make it more nimble to use.
So, my idea on this is that there should be a more structured way to dynamically mutate the size of a buffer on a stack.
At least some of its features would be:
* There should be a “stack buffer point” – A singular referenceable pointer that is accessible that indicates the start of the stack position where the dynamic buffer starts. Having multiple independent ones is not because of how a stack works.
* A facility that tells you how much stack is available and can be used – So that you don’t accidentally blow up the stack, and you can make an informed decision on either or not you want to allocate something on the stack or fallback to using the heap.
* A facility to resize how much of the stack is reserved – Which would allow you to decrease the amount of memory as well as increase it (right now we can only increase it with alloca).
Some constraints seem obvious, like functions that use dynamic stack can not be inlined by the compiler otherwise it could be ill formed.
But it has become quite clear to me that this task is a bit over my capabilities.
This is a call for help from people who might know more about how features like “alloca” works on different platforms, how compilers manage data on the stack, etc.
who would be willing to help and create a road map on how structured dynamic stack allocation should look like such that you can make it part of the standard.
Best regards,
Tiago
Received on 2025-01-14 21:14:32