bin_write_t__local, S_local, etc. Modal types are not supported by the public OCaml compiler, so the local type annotations are erased at the moment.Bin_prot.Util.Of_minimal1, which is a version of Bin_prot.Util.Of_minimal with different arity.Insert the changelog here. When making the release, we will keep this section and delete the section above.
In Bin_prot.Bin_shape, expose the structure of Expert.Canonical.t
Add a stable_witness idiom
Remove deprecated functions for dealing with float arrays.
ppx_bin_prot with type float array or floatarrayRemove the deprecated Make_binable* functor family
*_with_uuid or *_without_uuid alternativesbin_prot to use %expect tests. No functional changes.Maximum and Minimum submodules to Size so to allow for easy estimation of the space required for simple bin_prot'ed types.Binable.S_only_functionsBin_prot can be configured to use the primitives to read/write integers from bigarrays. This was never enabled due to missing tests that selecting this code path doesn't change the format.
This version add these tests and enable the use of the fast primitives.
Remove most use of cpp in bin_prot.
Replace the pre-processor conditionals by runtime one. This make the code a little less obfuscated.
ARCH_SIXTYFOUR to JSC_ARCH_SIXTYFOUR.Fixed to support 32-bit integers, which are used in js_of_ocaml.
Do not make too many assumptions on integer size. Integers are 32bit in Javascript.
Do not use the "get_float_offset" hack on 32bit as it cannot be implemented in javascript.
Sped up bin_io of float array.
Bin_prot already had special fast handling for float array's but with bin_io did not use it except for the special type float_array. Now, there is fast handling for float array and its aliases, for example price array when type price = float.
Size.bin_size_array, Write.bin_write_array and Read.bin_read_array short circuit to the fast path when it detects that float array is handled. Each of these functions receives a function for handling array elements and short circuits when the function for handling elements is equal to the function for handling floats, using physical equality of closures.float, changed bin_io so that aliased bin_io functions are equal the the bin_io functions of the original type. That is an optimization for itself regardless whether it's used for float. Before this change, every function generated for aliases were eta-expanded leading to different closures at runtime for each type.Short circuiting needs to apply to the handling function rather than to the value at hand because:
size and write, and we need a way to make read work as well.Made a slight improvement to bin_read_float_array: since the array is going to be filled with read values, there is no need to fill it with 0. after allocation:
let next = pos + size in
check_next buf next;
-| let arr = Array.create len 0. in
+| let arr = Array.make_float len in
unsafe_blit_buf_float_array buf arr ~src_pos:pos ~dst_pos:0 ~len;
pos_ref := next;The difference in speed when optimal and non optimal way of handling floats is used:
Name | Time/Run | mWd/Run | mjWd/Run |
|---|---|---|---|
[bench.ml:float array] size non optimal | 3_403.80ns | 2_000.00w | |
[bench.ml:float array] size float_array | 5.55ns | ||
[bench.ml:float array] size Price.t array | 6.18ns | ||
[bench.ml:float array] write non optimal | 7_839.89ns | 2_000.00w | |
[bench.ml:float array] write float_array | 292.42ns | ||
[bench.ml:float array] write Price.t array | 293.16ns | ||
[bench.ml:float array] read non optimal | 9_665.06ns | 2_002.00w | 1.00kw |
[bench.ml:float array] read float_array | 461.01ns | 2.00w | 1.00kw |
[bench.ml:float array] read Price.t array | 449.43ns | 2.00w | 1.00kw |
There is no observed speed penalty for runtime check for short circuiting. The following benchmark shows the speed of handling int array without and with the check:
Name | Time/Run | mWd/Run | mjWd/Run |
|---|---|---|---|
[bench.ml:float array] int array size | 3_910.64ns | ||
[bench.ml:float array] int array write | 6_548.40ns | ||
[bench.ml:float array] int array read | 14_928.11ns | 2.00w | 1.00kw |
Name | Time/Run | mWd/Run | mjWd/Run |
|---|---|---|---|
[bench.ml:float array] int array size | 3_906.86ns | ||
[bench.ml:float array] int array write | 5_874.63ns | ||
[bench.ml:float array] int array read | 14_225.06ns | 2.00w | 1.00kw |
Minor commit: comments.
Bin_prot.Blob, formerly known as Core_extended.Wrapped, which has efficient handling of size-prefixed bin-io values in cases where serialization can be bypassed.float and float array operations.Removed a use of Obj.magic in code generated by pa_bin_prot for polymorphic variants that led to memory unsafety.
Previously, pa_bin_prot generated this kind of code for polymorphic variants:
match Obj.magic (read_int buf pos) with
| `A as x -> x
| `B as x -> x
| `C -> `C (read_float buf pos)
| _ -> failand this caused the compiler to assume the result is an immediate value. To fix this we removed the as x -> x and used the computed integer hash.
Write, improved some OCaml macros to name values and avoid calling C functions multiple times.Remove "unwrapped" pointers used by Bin_prot, with the bug from 109.41 fixed.
Unwrapped pointers cannot coexist with the remove-page-table optimization.
Removed all the C stubs for reading/writing and used instead either the new primitives of the next OCaml or standard OCaml code reading/writing integers byte by byte.
Since we don't have unsafe/safe functions anymore but only safe ones, removed all the bin_{read,write}_t_ functions.
Also renamed bin_read_t__ to __bin_read_t__ for the same reason as sexplib: to avoid confusion with the function generated for t_ and hide it in the toplevel.
Remove all uses of "unwrapped" pointers
Unwrapped pointers cannot coexist with the remove-page-table optimization.
Removed all the C stubs for reading/writing and used instead either the new primitives of the next OCaml or standard OCaml code reading/writing integers byte by byte.
Since we don't have unsafe/safe functions anymore but only safe ones, removed all the bin_{read,write}_t_ functions.
Also renamed bin_read_t__ to __bin_read_t__ for the same reason as sexplib: to avoid confusion with the function generated for t_ and hide it in the toplevel.
Fixed build problem with gcc 4.4 due to stricter checking for empty macro arguments.
Thanks to Nobuyuki Tomiza nobuyuki.tomizawa@gmail.com for the patch!