[MLton-user] How to access large amounts of data through FFI
Ville Tuulos
tuulos at gmail.com
Fri Oct 10 11:24:09 PDT 2008
Hi
I'm a total SML / Mlton newbie, so please excuse my ignorance.
I'm trying to find out if I could use Mlton to perform some data
processing tasks that I used to do in C, or slowly in Python. I have
large amounts (hundreds of megs to a gigabyte) of data memory mapped
(using mmap) to my process' address space in C. The mapping is
read-only.
I would like to access the data in Mlton without copying it first, due
to obvious performance reasons. The data itself is a flat array of
native 32-bit ints. Since it's an immutable array of native ints, I
was hoping that I could access it as an int vector (or something
similar) in Mlton.
How to construct and pass a valid int vector from C to SML through
Mlton's FFI, preferably without copying the data first? The FFI
interface seems pretty straighforward but I couldn't find any
documentation how arrays and vectors should be initialized based on a
C pointer and size of the data. Or, if the int vector is not a good
idea, what would be a better way to get access to the memory space?
Thank you,
Ville Tuulos
More information about the MLton-user
mailing list