-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stdlib: Mirror IO_BUFFER_SIZE and UNIX_BUFFER_SIZE in the stdlib and unix lib #13589
base: trunk
Are you sure you want to change the base?
Conversation
04ba8da
to
8388a24
Compare
Thanks @EruEri for making the ball roll on that one. I have however one question for upstream. Is it really worth having separate constants for Unix and Sys ? Shouldn't we simply unify unix and sys to both use IO_BUFFER_SIZE and and simply expose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have however one question for upstream. Is it really worth having separate constants for Unix and Sys ?
If we believe that the existing API semantics of Unix
are unlikely to change substantially in the future (which seems likely), then I guess we could do as suggested.
Incidentally, the constant UNIX_BUFFER_SIZE
was initially introduced in d75dd36 and increased to its current value in 1ecb1f4. IO_BUFFER_SIZE
was set to its current value in cf1071e.
@damiendoligez: do you have an opinion?
(** Size of the buffer channels | ||
|
||
@since 5.4 | ||
*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring should be expanded. The whole point of this PR is to document an existing constant to avoid hard-coding values in user programs. Thus, I would expect that the docstring would explain which buffers are concerned, and how is this constant can be used in user programs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about “All channels are buffered by default. You may want to perform reads or writes of sizes equal to the buffer size to maximize throughput in certain situations, for instance.”
CAMLprim value caml_unix_io_buffer_size(value unit) | ||
{ | ||
return Val_long(UNIX_BUFFER_SIZE); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the constant is the same for both the Unix and Win32 backends, I would expect the definition of the function to be shared. However, I don't see right away a file where it could be put.
#5938
Hi,
I tried to export those value to make it available in Ocaml, but I'm not sure whether the c functions are written in the appropriated files ?