-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support Dynamically Sized fields #8
Comments
Any idea how to do this with standard java types without call site modification? |
My initial plan was to support arrays of primitives, and possibly a few important other types like strings. I haven't got any particularly smart ideas on this front though. I mean its entirely doable to support them via resizing the entire slab and copying memory. That might be fine for some people, but maybe not so much for others. A possible improvement would be to provide an annotation to say always allocate n items for a dynamically sized field, even if it involves wasted space. Over time it might be possible to learn sizing heuristics based upon the tradeoffs between copying and wasted memory. If you have good suggestions, feel free to comment. |
Since we're using Unsafe for optimisations, copying & resizing don't seem like attractive solutions. My slabs are immutable and long-lived so I haven't thought about resizing dynamic fields much, but as for reading them, I've had to write my own string/array operations that typically involve looping each primitive and using Unsafe.getChar, etc. Clearly that's a mess, so I've recently considered using flyweights that extend CharSequence for strings, but there are likely to be limitations on what I can do with it. I'm not sure what to do for arrays. Another idea is exposing functions that would normally require new object construction to work properly (e.g. part of slab -> byte array -> new string) but using something like ASM to stub out the object creation and replace any usage of the expected object with methods that use Unsafe on the original data. This is much more advanced. Perhaps a little bit crazy.. |
I guess the key question when you've got your immutable, long lived slabs A CharSequence wrapper is something to look into. |
String, byte[] etc.
The text was updated successfully, but these errors were encountered: