OCamlPro/opam-repository — pull request #875 by ysulsky (2013-07-03 19:45:04+00:00)
Title: core-109.32.00 rc1

## Async_core

- Improved the batching of `Pipe.fold` and other `Pipe` functions that handle batches.

Previously, such functions used a loop with `Pipe.read`. This didn't
batch as well as it might. If values were put in the pipe after the
`read` becomes determined but before the values are handled, then they
wouldn't be handled until the next batch. Now, batching functions use
`values_available` and then pull elements out of the pipe
synchronously after waking up. This makes the batch as large as
possible.

## Async_extra

- Added `Dynamic_port_writer`.

`Dynamic_port_writer` solves the problem of communicating a
dynamically selected tcp port from a child process to its parent.

## Core

- Normalized `Command`'s help messages.

Made anonymous argument names uppercase and subcommand names lowercase.

- In `Iobuf`, added duals to `flip` and `snapshot` to work on the high end of the window.

`flip` has been renamed to `flip_lo`. The dual of `flip_lo` is the
newly added `flip_hi`, and shifts the window forward to continue
reading, rather than back to switch from writing to reading, as
`flip_lo` does.

`flip_hi`, in practice, needs snapshots of the upper bound of the
window, we split `Snapshot` into `Lo_bound` and `Hi_bound` and
introduced bounded versions of `flip_lo`, `compact`, and `flip_hi` to
support buffers which are only partially filled, but have
substructure, like packet buffers.

Here's the new API.

```ocaml
module type Bound = sig
type ('d, 'w) iobuf

(** Expose =t = private int= only if a =t= is stored in a mutable data structure
somewhere and leads to a measurable =caml_modify= performance problem. *)
type t with sexp_of

val window : (_, _) iobuf -> t
val limit : (_, _) iobuf -> t
val restore : t -> (_, seek) iobuf -> unit
end
module Lo_bound : Bound
module Hi_bound : Bound
val flip_lo : (_, seek) t -> unit
val bounded_flip_lo : (_, seek) t -> Lo_bound.t -> unit
val flip_hi : (_, seek) t -> unit
val bounded_flip_hi : (_, seek) t -> Hi_bound.t -> unit
```

## Core_bench

- Changed `-save` to output compaction information.

- Added indexed tests.

These are benchmarks of the form `int -> unit -> unit`, which can be
profiled for a list of user specified `int`s.

## Core_kernel

- Added `val Option.merge: 'a t -> 'a t -> f:('a -> 'a -> 'a) -> 'a t`.

- Added `val Validate.failf : ('a, unit, string, t) format4 -> 'a`.

- In `Validated.Make_binable`, made it possible to apply the validation function when un-bin-io-ing a value.

- Added `module Pooled_hashtbl` to `module type Hashable`.

This is an alternative implementation to `Core.Hashtbl`. It uses a
standard linked list to resolve hash collisions, and `Pool` to manage
the linked-list nodes.

## Ocaml_plugin

- Fixed the slow and memory-consuming compilation of > 100MB `.c` files generated by `ocaml_embed_compiler`.

This was done by having them contain one big string instead of one big
array.

- Added more unused-value warnings in plugins.

If { `Ui` , `M` } are the modules that constitute a given plugin of
expected module type `S`, then previously we generated a file like:

```ocaml
module Ui : sig
...
end = struct
...
end

module M : sig
...
end = struct
...
end

let () = ##register (M : S)
```

Doing that, we did not get unused variables:

1. for the toplevel of `Ui` if `Ui` does not have a `mli`.
2. for unused values of `Ui` and `M` if they have an `mli` exporting them.

OCaml plugin now allows one to get these warnings. Since (2) is
rather annoying for utils kind of file, this comes only if a config
flag is enabled.

## Re2
- Fixed a bug in the C bindings that could cause a segfault.

Fixed a bug where `mlre2__create_re` in C can give OCaml a freed C string.

The bug was in:

```c
if (!compiled->ok()) {
compile_error = compiled->error().c_str();
delete compiled;
compiled = NULL;
caml_raise_with_string(*caml_named_value("mlre2__Regex_compile_failed"),
compile_error);
}
```

This is in `mlre2__create_re` if we fail to compile the regular
expression. Notice how we delete the re object before we use the pts
to its' error string. (Notice that in C++ `c_str()` returns a pointer
to the internal data of the string object it does NOT create a copy
and `error()` just returns a reference to the regular expression objects
error string member `*error_`).

So if `caml_raise_with_string` has to allocate on the heap to create
the exception or the copy of the string that might invalidate the ptr
before we will copy it.