That kind of reminds me of dumpable [1] library doing a similar thing in C++. [1] https://github.com/ipkn/dumpable
Zero-copy deserialization in Julia
11–20 of 34 posts
Re: Zero-copy deserialization in Julia
#12Re: Zero-copy deserialization in Julia
#13Re: Zero-copy deserialization in Julia
#14Other languages with macros can do this sort of thing but one then needs to “derive blob” or something like that.
In Haskell one could probably do it with Generic (ie the compiler generates a data representation of the type; you write a function to go from this representation to your deserialisation function; and then the compiler does a crazy amount of inlining)
An alternative way to do this in an object oriented language is with a different metaclass that does the appropriate dereferencing. But this risks being slow if not compiled well
Re: Zero-copy deserialization in Julia
#15So, I have to check that libraries don't do this if I am to rely on the idea that Julia offers safety?
Graphics card drivers are WAY out. File systems too.
Julia offers as much safety as most languages. You would be hard pressed to find a language which doesn't let you pull something like this.
Julia wouldn't solve the 2 languages problem if there was a lot of things you would have to drop back to C to do....
Re: Zero-copy deserialization in Julia
#16I originally wrote it to analyze large data sets (where "large" meant 16+ GB which was much larger than the commonly available RAM at the time).
It integrated nicely with OCaml. You could create ordinary OCaml objects then incrementally "mark" them so those objects would be moved (recursively) into the ancient heap. The objects could still be accessed as if they were ordinary OCaml objects even if they were on the ancient heap. On the other side you could mmap a previous heap and access the objects as if they were regular OCaml objects directly (with a few shortcomings - see README). Depending on your access pattern this worked well even if available RAM was much smaller than the size of the data set.
[1] http://git.annexia.org/?p=ocaml-ancient.git;a=blob;f=README....
Re: Zero-copy deserialization in Julia
#17This reminds me of the OCaml "Ancient" library[1] that I wrote. It lets you have an extra heap of OCaml objects which can be stored in an mmap'd file and even shared between processes (although the sharing must be read-only and has a number of problems like everything has to be mapped at the same address which conflicts with ASLR - we didn't use pointer offset conversion as done in this article because it would touch…
Re: Zero-copy deserialization in Julia
#18Re: Zero-copy deserialization in Julia
#19I suppose the real Julia trick used to make this nice is the generated function. There isn’t really anything like this in C without code generation. Other languages with macros can do this sort of thing but one then needs to “derive blob” or something like that. In Haskell one could probably do it with Generic (ie the compiler generates a data representation of the type; you write a function to go from this represent…