-
Notifications
You must be signed in to change notification settings - Fork 13
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
would it be possible to reduce the dependencies of core_bench? #18
Comments
core_bench
?
It's possible, for sure, but it's a real amount of work. Core_bench depends on Core, as well as command, and it's tricky to get all the functionality in the command-line tool, including the autocompletion support, without depending on Core, and at least Core_kernel. Also, a lot of the included libraries are also packaged together. i.e., ansi_kernel, which is on the dependency table for creating pretty tables full of results, is packaged together with core_kernel, which means that even if we move its dependency from core_kernel to base, requesting it in opam will still build core_kernel for you. I think a story for doing this would probably require:
We've left a lot of packages in core_kernel that aren't strictly necessary there because we didn't want to overwhelm opam with lots of tiny little packages. There's around 35 little libraries in core_kernel's opam package that aren't part of core_kernel proper. The downside of this is that it means that building core_kernel is a lot slower than it would otherwise need to be. Maybe this is something that we could fix more easily? By the way, I suspect you'll find that most of the extra time is the building of Core and Core_kernel, and not the PPXs. How urgent is a fix here? The earliest time that I think you'd get a useful version of the fix is at our next stable release anyway. Am I correct in assuming you're not using the bleeding edge version? |
Thanks for the quick reply! There is nothing urgent. It's more about making something nice that is a bit inconvenient right now. Maybe it would be worth asking your compiler-hacking people if they would also benefit from such a change. (It may be that other people felt the need but did not bother reporting it.) Having looked at Core_bench sources briefly recently, I realize that there are a lot of features in there that require external-libraries support (for example export to various formats, etc.). Going along your reply: maybe rather than trying to slim down core_bench with its current feature set, it would be easier to carve out the core logic we typically use for barebones microbenchmarking (precise timing (already a separate dependency), benchmark estimation, running benchmarks and minimal reporting) in a separate package (base_bench ? :-). It would only offer a more restricted feature set, on top of which core_bench could come with all bells and whistles. |
Yeah, that's essentially what I meant when I talked about breaking out a "kernel" library. I guess an open question is what features would actually be required to make such a library useful. Notably, how much of the pretty tabular reporting would one be willing to jettison? |
Here is a pretty table produced by
I can reproduce this output exactly with the following code: type justification = Left | Right
type table = {
arity: int;
justif: justification array;
header: string array;
rows: string array list;
}
let max_width ~column table =
List.fold_left
(fun w r -> max w (String.length r.(column)))
(String.length table.header.(column)) table.rows
let to_pretty_string table =
let widths = Array.init table.arity (fun i -> max_width ~column:i table) in
(* each column is printed with a space on both sides,
so the apparent width is widths.(i) + 2 *)
let buf = Buffer.create 42 in
let printf fmt = Printf.bprintf buf fmt in
let print_text ~column:i s =
printf
(match table.justif.(i) with
| Right -> " %.*s "
| Left -> " %-.*s ")
widths.(i) s in
let print_row row =
row |> Array.iteri (fun i s ->
printf " ";
print_text ~column:i s);
printf " \n";
in
let print_header_line () =
for i = 0 to table.arity - 1 do
printf " %s" (String.make (1 + widths.(i) + 1) '-');
done;
printf " \n";
in
print_row table.header;
print_header_line ();
List.iter print_row table.rows;
Buffer.contents buf |
@gasche I expect that you can re-implement the whole library and provide the same set of features with a fraction of the overall amount of code required to build For the rest, it's not that we are not interested in fast compilation times or small binaries, in fact we are putting a lot of effort into both, however we are mostly interested in solutions we can apply systematically. Duplicating a functionality already provided by another library feels a bit too ad-hoc, even if it is (initially) not that much code. It would strictly increase the amount of code we have to maintain, which doesn't feel right. The right way to go about all this is to first understand where the time is being spent. 6m to build core_bench feels pretty high, even considering the amount of dependencies. We have been working on assembling a buildable repository that contains all our code: It's not yet quite ready, but soon you'll be able to go there and run |
Actually, I just gave it a try. You just have to clone ppxlib and it works:
The last command takes just a bit less that 1 minute on the machine I'm using. By comparison, "opam install core_bench" with everything pre-downloaded takes 2m42s. So we could win a factor of almost 3 simply by making the tooling more clever. |
Another data point, I did the following:
I'll skip the details, but essentially it is building exactly the same thing as "opam install core_bench". Including all the non-necessary code in core/core_kernel. The last command takes 1m15s for me, compared to the 2m42s with opam. So simply by changing the way opam build and install things, we could cut installation times by more than 2. @avsm mentioned the idea that rather than building and installing packages one by one, opam could build them all at once with a single |
I have updated core_bench in our internal repo to drop most of the ppx dependencies, except for the few it actually uses. The public release process should push out the change before long. I didn't clean up any other dependencies - I think the biggest source left is core. Currently all our time representations come from core, so until we separate those I think we're not going to do much better. |
Thanks! |
The change @ceastlund mentions landed in f319e14. I'm not sure if this "closes" the issue as there seems to be a lot of ideas being discussed. |
I would like to use the faster-map benchmark to test ongoing work on tail-recursion-modulo-cons ( ocaml/ocaml#181 ); this means creating an empty switch from an experimental compiler, then building
faster-map
's dependencies.The dependencies are as follows:
dune batteries containers core_bench
. Building this from an empty switch is fairly slow on my machine, and most of the time is spent compiling dependencies ofcore_bench
:Would there be interest among core_bench maintainers to make it more pleasant to use for compiler-optimization microbenchmarking? It may not be that much work to reduce the dependency surface. (I understand that you need access to fine-grained timers, but for example it is not clear why core_bench depends on ppx_jane and many ppx extensions.)
(cc @ksromanov who kindly updated faster-map for TRMC testing.)
The text was updated successfully, but these errors were encountered: