Skip to content
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

A faster version of Array.sub implemented in C #4591

vicuna opened this issue Jul 28, 2008 · 1 comment

A faster version of Array.sub implemented in C #4591

vicuna opened this issue Jul 28, 2008 · 1 comment


Copy link

@vicuna vicuna commented Jul 28, 2008

Original bug ID: 4591
Reporter: technophobicgeek
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2011-12-21T10:38:13Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.10.3+dev
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #2395 #2787
Monitored by: "Richard Jones" @dbuenzli @alainfrisch

Bug description

This is a C implementation of Array.sub, which I believe should deal with some of the inefficiencies in the current OCaml implementation of Array.sub in the OCaml std library.

From the discussion on the caml-list

This code is patterned after caml_make_vect function in the OCaml compiler.

I don't think that C is the main reason for the improvement, it's more

  1. The OCaml library version of Array.sub creates an array,
    initializes it, and then copies to it. The initialization is quite
    unnecessary, and algorithmically makes the function about twice as
    expensive as it should be.

  2. From reading OCaml source code, it looks like caml_initialize is a
    much cheaper function to use than caml_modify due to GC issues. Yet, the
    OCaml library version uses caml_modify by initializing the target array
    with a default value first, instead of using the source array to
    initialize. I guess this is why on profiling, caml_modify shows up as
    really expensive, paired with lots of GC calls.

File attachments

Copy link

@vicuna vicuna commented Dec 21, 2011

Comment author: @xavierleroy

Faster implementations of "Array.blit", "Array.copy", "Array.sub", "Array.append" and "Array.concat" now integrated in SVN trunk (commit 11913).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants