-
Notifications
You must be signed in to change notification settings - Fork 228
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
Improve speed by moving function collections to stack arrays #12
Comments
This might not actually be possible with modern rust. Apparently it might require VLA (variable length arrays), which do not exist today because they're easy to blow through the stack with. Will remove the milestone but keep the issue open for future review. Arrayvec could work today if we specify a compile time upper bound, but I'm not sure we want to do that because it seems like an artificial limitation to our users. |
Related RFC issue: rust-lang/rfcs#618 |
If we don't have rust support for this (and this does indeed turn out to be a significant speed issue - which it may not) we could add some sort of scoped helper method which takes a fn and calls it on a C |
rust-lang/rust#48055 might be a better approach to this |
Added experimental feature flag for testing this: 673a3d5 |
A common pattern being used looks something like this:
What we're basically doing is taking a bunch of our own types and mapping them to a sequence of raw llvm pointers. The problem is that Vec will allocate on the heap, but this sequence is only needed for the scope of the function and never gets directly returned. So, I think we can improve this pattern by using something like arrayvec which stores the contents on the stack. This should also work really well because we never modify the size of these vectors, just use them as an intermediate data location for LLVM to read from.
Alternatively, if there's a way to just collect into a a stack slice, that would work too.
This might make for a good first PR if anyone's interested since it doesn't require technical knowledge of LLVM, just Rust.
The text was updated successfully, but these errors were encountered: