-
Notifications
You must be signed in to change notification settings - Fork 6
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
Approach to alloc
#5
Comments
I think GCs would have to be implemented at the compiler level. Julia's GC isn't aware of/doesn't handle I think "better performance than One fairly easy option I'd like is letting it allocate "stacks" we can use manually with a bump allocator. One possible version is to allow a maximum of up to 128 be used at a time, with something like: struct BumpAlloc
memory::Vector{Vector{UInt8}}
mask::Base.Threads.Atomic{UInt128}
BumpAlloc() = new([UInt8[] for _ in 1:128], Threads.Atomic{UInt128}(typemax(UInt128)))
end The mask indicates whether each vector is used. They'd have to have a way to estimate how much memory they'll actually need, so that they can Allocating means setting the mask bit to Using this bump allocator itself is cheaper, allocating is incrementing the returned pointer, freeing is a no-op. |
I'm all in favor of having more unique ways of allocating memory and Also we might have |
I'd love to have an
alloc
method in this package, but I'm not aware of any consensus on how this should be approached in Julia (besidesLibc.malloc
). Packages with related functionality includeBlob.jl
,StructIO.jl
, and an unregisteredManualMemory.jl
package. I'm sure there are others, along with plenty of relevant discussions on Zulip and in other issues.I'm hoping we can converge on some well-defined goals here for functionality and possibly a path to implementation. So here are some goals I was thinking of:
Libc.malloc
. push!/pop! always does a ccall JuliaLang/julia#24909 (comment)I'm not entirely sure what this will require. Other packages have plenty of code on how to map memory to julia types that could be built on top of, but I think the only way to allocate memory that the GC is aware of is to use
alloca
from LLVM, but I never was able to get that to return unique pointers.Edit: Looks like there's an LLVM based implementation here.
The text was updated successfully, but these errors were encountered: