garciaes
garciaes

Reputation: 21

can we customize the file open buffer size in Julia

open() sets a memory buffer as defined by io.h: IOS_BUFSIZE = 32kb (previously 128kb)

Is it possible to change that value (future open kwargs?) or adapt it to disk blocksize (often very large in GPFS, etc)?

Upvotes: 2

Views: 137

Answers (1)

SGJ
SGJ

Reputation: 1058

As far as I can tell, it's currently not possible to change this from Julia (short of re-implementing ios.c:_buf_realloc in Julia). It would be pretty easy to add this feature to Julia via a PR. e.g. add something like the following to src/support/ios.c:

int ios_growbuf(ios_t *s, size_t sz)
{
    return _buf_realloc(s, sz) == NULL;
}

and then something like the following in base/iostream.jl:

function sizehint!(s::IOStream, sz::Integer)
    ccall(:ios_growbuf, Cint, (Ptr{Cvoid}, Csize_t), s.ios, sz) != 0 &&
        throw(OutOfMemoryError())
end

Upvotes: 2

Related Questions