Make [read_all] work for channels that are not files#3162
Make [read_all] work for channels that are not files#3162aalekseyev merged 11 commits intoocaml:masterfrom
Conversation
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
|
Looks good. Let's add a change log entry since this is probably confusing a lot of linux users. |
|
Did we do a release since the bug was introduced? |
|
Yup... 2.3 contains this bug |
|
... and is missing any relevant changelog entry. Should I put one retroactively, or do we not do that? |
|
Well, the PR that introduced the bug simply improved an error message for Mac vs Linux users. It didn’t seem like a change log entry was warranted.
…On Feb 19, 2020, 12:06 PM +0000, Arseniy Alekseyev ***@***.***>, wrote:
... and is missing any relevant changelog entry. Should I put one retroactively, or do we not do that?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
I guess the mention of when the bug was introduced in 2.4.0's changelog should be sufficient. Pushed that. |
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
ca6bc56 to
366a62d
Compare
|
I think if we have to fstat to apply this optimization, the benefits of this optimization might be wiped out.
What about keeping the old implementation under something like:
val read_channel_i_know_its_a_file : in_channel -> string
…On Feb 19, 2020, 2:40 PM +0000, Arseniy Alekseyev ***@***.***>, wrote:
@aalekseyev commented on this pull request.
In src/stdune/io.ml:
> @@ -109,9 +109,22 @@ struct
};
f lb)
- let read_all ic =
- let len = in_channel_length ic in
- really_input_string ic len
+ (* This function is a copy&paste from Jane Street's [Stdio.In_channel.input_all]. *)
+ let read_all t =
+ (* We use 65536 because that is the size of OCaml's IO buffers. *)
+ let buf_size = 65536 in
+ let buf = Bytes.create buf_size in
+ let buffer = Buffer.create buf_size in
+ let rec loop () =
I guess in_channel_length returns zero because we ended up with an empty string in the case of non-file. I'm not very familiar with the in_channel API. Is there a way to fstat the thing?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
Nevermind, I though |
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
|
I let you check the new code, it's a bit more complicated but it seems worth it to me. I'm always wary of these temporary buffers putting pressure on the gc. |
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
|
By the way, it looks like And in fact linux does raise an error when |
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
|
Ah ok, that makes more sense. |
…lugin, dune-private-libs and dune-glob (2.3.1)
CHANGES:
- Fix versioning of artifact variables (eg %{cmxa:...}), which were introduced
in 2.0, not 1.11. (ocaml/dune#3149, @nojb)
- Fix a bug introduced in 2.3.0 where dune insists on using `fswatch` on linux
(even when `inotifywait` is available). (ocaml/dune#3162, @aalekseyev)
- Fix a bug causing all executables to be considered as optional (ocaml/dune#3163, @diml)
…lugin, dune-private-libs and dune-glob (2.3.1)
CHANGES:
- Fix versioning of artifact variables (eg %{cmxa:...}), which were introduced
in 2.0, not 1.11. (ocaml/dune#3149, @nojb)
- Fix a bug introduced in 2.3.0 where dune insists on using `fswatch` on linux
(even when `inotifywait` is available). (ocaml/dune#3162, @aalekseyev)
- Fix a bug causing all executables to be considered as optional (ocaml/dune#3163, @diml)
…lugin, dune-private-libs and dune-glob (2.3.1)
CHANGES:
- Fix versioning of artifact variables (eg %{cmxa:...}), which were introduced
in 2.0, not 1.11. (ocaml/dune#3149, @nojb)
- Fix a bug introduced in 2.3.0 where dune insists on using `fswatch` on linux
(even when `inotifywait` is available). (ocaml/dune#3162, @aalekseyev)
- Fix a bug causing all executables to be considered as optional (ocaml/dune#3163, @diml)
…lugin, dune-private-libs and dune-glob (2.3.1)
CHANGES:
- Fix versioning of artifact variables (eg %{cmxa:...}), which were introduced
in 2.0, not 1.11. (ocaml/dune#3149, @nojb)
- Fix a bug introduced in 2.3.0 where dune insists on using `fswatch` on linux
(even when `inotifywait` is available). (ocaml/dune#3162, @aalekseyev)
- Fix a bug causing all executables to be considered as optional (ocaml/dune#3163, @diml)
This fixes a bug where
Sys.linuxis not detected properly because/proc/sys/kernel/ostypeis not a file.