Deprecation of Bigarray.*.map_file and introduction of Unix.map_file, continued#1077
Deprecation of Bigarray.*.map_file and introduction of Unix.map_file, continued#1077
Conversation
|
From appveyor: |
|
Thanks for the ping. Pushed a trivial fix for the failing test. |
| with | ||
| | Unix.Unix_error((Unix.EACCES | Unix.EPERM), _, _) -> true | ||
| | Unix.Unix_error(err, _, _) -> | ||
| Printf.eprintf "Unexpected error %s\n" (Unix.error_message err); |
There was a problem hiding this comment.
It would be nice to include a flush %! to the format to avoid delayed printing. (Same below)
|
It looks like the test still fails on Windows: (@xavierleroy: I'm writing this tautologic message because I'm not sure you have seen the last failure; I myself don't get notifications when the CI results are available, which would be convenient, so I have to resort to polling; given that I just did a polling cycle I thought you could be interested in a delayed notification. Feel free to grumble otherwise.) |
|
@xavierleroy I think we need to reference at least one stub from |
|
@gasche : like you, I poll occasionally. I'm on the Win32 test failure. @diml : I ran into the issue you mention. Currently, it is avoided by forcing the registration of |
|
All right, it seems that CI is happy (the Travis failure is because of no Changes entry, despite the label to that effect), so I turned off the fasten seat belts sign ^H^H^H^H^H^H I removed the work-in-progress label to indicate that this PR is ready for code review. (Yay.) I'm sorry that it turned out a little more complicated than I hoped. On the other hand, some of the |
|
(It would definitely make sense to add the number of the present GPR to the GPR#997 change entry, so that people can have the full picture.) |
|
Fair enough, in the end I updated the Changes file. |
|
@diml, do you think it would be possible for you (or someone else) to review this proposed change in the following days? This is the only remaining blocker that I am aware of for Camomile, which means that after this is merged (or, if this takes too long, after #997 is reverted as a first step), I could ask @lefessan to update the |
|
@gasche sure, I was planning to look at this today or tomorrow |
|
Thanks! |
| Assert((flags & CAML_BA_KIND_MASK) <= CAML_BA_CHAR); | ||
| for (i = 0; i < num_dims; i++) dimcopy[i] = dim[i]; | ||
| asize = SIZEOF_BA_ARRAY + num_dims * sizeof(intnat); | ||
| res = caml_alloc_custom(&caml_ba_mapped_ops, asize, 0, 1); |
There was a problem hiding this comment.
What is the motivation for using 0, 1 rather than size, CAML_BA_MAX_MEMORY as before? Isn't that bad if shared=false for instance?
There was a problem hiding this comment.
BTW, I never remember how these values are interpreted, so 0, 1 might be the right setting, but I would think it's safer to be conservative for the upcoming release
There was a problem hiding this comment.
The old code used 0 and CAML_BA_MAX_MEMORY in this case (i.e. size is 0 for mmaped bigarrays), so the new code behaves like the old code. Whether it is the right thing to do is unclear.
There was a problem hiding this comment.
Indeed, I missed that the size was 0 in the old code
| It is included for backward compatibility with the old | ||
| Bigarray.*.map_file implementation. */ | ||
|
|
||
| static void caml_ba_sys_error(void) |
There was a problem hiding this comment.
You're correct, wrong cut and paste from ../unix/mmap.c. Fixed.
|
In byterun/bigarray.c:
Incidentally, in byterun/caml/misc.h one reads: #ifndef CAML_AVOID_CONFLICTS And it seems it's the only place in the repo that mentions this And finally, before merging, wouldn't it be worth sending this PR to precheck? |
|
@shindere : OK for Concerning the header, it is the same as for otherlibs/bigarray/bigarray_stubs.c, from which byterun/bigarray.c was excerpted. Yes, the bigarray_stubs.c dates back to 2000, was written with the help of Manuel Serrano, and I was located in Rocquencourt at this time. We don't have a policy of updating file headers, so why not keep the original header? |
|
Thanks, @xavierleroy. I'm very fine with anything. Just wanted to make
sure it was not a mistake.
Re Assert: shall we get rid of CAML_AVOID_CONFLICTS and of Assert
itself and consistently replace it by CAMLassert everywhere?
|
That would be a good thing, but of course not in this PR. |
|
Damien Doligez (2017/03/09 05:08 -0800):
>Re Assert: shall we get rid of CAML_AVOID_CONFLICTS and of Assert itself and consistently replace it by CAMLassert everywhere?
That would be a good thing, but of course not in this PR.
Sure. Will do it in a different PR. Can Assert be removed completely,
all should it rather be moved to compatibility.h?
I would personnally remove it because as far as I know it is not
documented so user-code is not supposed to use it.
|
|
Yes, remove it completely. |
|
The windows CI is failing with: Otherwise the I read the changes and the patch looks correct to me. |
This reverts commit 5ed7200. GPR#997 introduced a hard dependency of Bigarray on Unix, while there previously only was a type-level dependency. This break some programs, such as Camomile, that linked bigarray.cma but not unix.cma. A solution is being worked out in GPR ocaml#1077 to remove the dependency, but I would like to go forward with opam package testing on the 4.05 branch, and getting the details right for GPR#1077 requires some care, so I wouldn't feel comfortable rushing to merge it. I had to handle the following conflicts: otherlibs/unix/unix.mli ("@SInCE 4.05.0" was added in faab91a) testsuite/tests/lib-bigarray-file/mapfile.ml (changed by 5839c98; I kept and adapted the new version) testsuite/tests/lib-bigarray-file/mapfile.reference
This reverts commit 5ed7200. GPR#997 introduced a hard dependency of Bigarray on Unix, while there previously only was a type-level dependency. This break some programs, such as Camomile, that linked bigarray.cma but not unix.cma. A solution is being worked out in GPR ocaml#1077 to remove the dependency, but I would like to go forward with opam package testing on the 4.05 branch, and getting the details right for GPR#1077 requires some care, so I wouldn't feel comfortable rushing to merge it. I had to handle the following conflicts: otherlibs/unix/unix.mli ("@SInCE 4.05.0" was added in faab91a) testsuite/tests/lib-bigarray-file/mapfile.ml (changed by 5839c98; I kept and adapted the new version) testsuite/tests/lib-bigarray-file/mapfile.reference
|
CI systems force us to realize that we work to make the machine happy, and not the other way around. |
743bf00 to
a239dc1
Compare
… continued This is a follow-up to GPR #997 with a different implementation that creates fewer dependencies. We add to the runtime a `byterun/bigarray.c` file that contains the bigarray creation functions that used to be in `otherlibs/bigarray/bigarray_stubs.c`. In the latter file we keep all primitives needed to implement the Bigarray interface. The functions in the new `byterun/bigarray.c` make it possible to create bigarrays both from the bigarray library and from the unix library. The header file `bigarray.h` moves to `byterun/caml/bigarray.h` accordingly. The `map_file` implementations move to `otherlibs/unix/mmap.c` and `otherlibs/win32unix/mmap.c`. Some bigarray allocation code shared between the two implementations is put in `otherlibs/unix/mmap_ba.c`. Through a couple of `#ifdef`, the `map_file` implementations can also be compiled from within `otherlibs/bigarray` with the same semantics they had in 4.04. As a consequence, the bigarray library still contains a standalone, Unix-independent implementation of `Bigarray.*.map_file`; the only difference with 4.04 is that it is marked deprecated. Current status: compiled and lightly tested under Unix. Win32 implementation neither compiled nor tested.
caml_unix_map_file and related functions were defined both in the stub lib for Unix and in the stub lib for Bigarray. This caused strange behavior when both Unix and Bigarray were linked, as found by the extra tests. The extra tests (all two of them) check that Unix.map_file raises reasonable Unix_error exceptions in common error cases.
Also: cosmetic improvement to corresponding test.
Follow-up to e763c83
179ad24 to
8afbd72
Compare
|
One more conflict resolved. One more rebasing done. I'm getting tired. Can we please merge? pretty please? |
|
The CI is "all green" and the merge target is trunk. I think it's an easy choice to merge -- let's do it right now. But the real question is whether you also want to merge this in 4.05? |
|
This broke CI because the defined MAP_FILE clashes with a macro defined in Fix pushed to trunk: a01cfa2 |
|
Xavier Leroy (2017/03/14 12:26 -0700):
@shindere : thanks for fixing this problem that I should have seen
coming!
My pleasure!
|
|
Other fix pushed to trunk: a6d7705 |
This reverts commit 5ed7200. GPR#997 introduced a hard dependency of Bigarray on Unix, while there previously only was a type-level dependency. This break some programs, such as Camomile, that linked bigarray.cma but not unix.cma. A solution is being worked out in GPR ocaml#1077 to remove the dependency, but I would like to go forward with opam package testing on the 4.05 branch, and getting the details right for GPR#1077 requires some care, so I wouldn't feel comfortable rushing to merge it. I had to handle the following conflicts: otherlibs/unix/unix.mli ("@SInCE 4.05.0" was added in faab91a) testsuite/tests/lib-bigarray-file/mapfile.ml (changed by 5839c98; I kept and adapted the new version) testsuite/tests/lib-bigarray-file/mapfile.reference
This is a follow-up to GPR #997 with a different implementation that creates fewer dependencies.
We add to the runtime a
byterun/bigarray.cfile that contains the bigarray creation functions that used to be inotherlibs/bigarray/bigarray_stubs.c. In the latter file we keep all primitives needed to implement the Bigarray interface. The functions in the newbyterun/bigarray.cmake it possible to create bigarrays both from the bigarray library and from the unix library.The header file
bigarray.hmoves tobyterun/caml/bigarray.haccordingly.The
map_fileimplementations move tootherlibs/unix/mmap.candotherlibs/win32unix/mmap.c. Some bigarray allocation code shared between the two implementations is put inotherlibs/unix/mmap_ba.c.Through a couple of
#ifdef, themap_fileimplementations can also be compiled from withinotherlibs/bigarraywith the same semantics they had in 4.04.As a consequence, the bigarray library still contains a standalone, Unix-independent implementation of
Bigarray.*.map_file; the only difference with 4.04 is that it is marked deprecated.Current status: compiled and lightly tested under Unix. Win32 implementation neither compiled nor tested. I'm submitting it as a GPR so that it gets some CI.