Re: [MLton] [MLton-user] List and String concatenation speed.

Matthew Fluet <[email protected]> Sun, 20 Aug 2017 07:42:31 -0400
Newsgroups gmane.comp.lang.ml.mlton.devel
Message-ID <CAMrhFL6KZe-RX1P8UcQ=dvrcqunL-kfNc4kqTsWXAYDy+qNJQg__32048.2899588116$1503230977$gmane$org@mail.gmail.com>
On Tue, Aug 30, 2016 at 3:44 PM, Matthew Fluet <[email protected]> wrote:
> On Tue, Aug 30, 2016 at 10:39 AM, Kostirya <[email protected]> wrote:
>> Many thanks!
>> I use
>>
>> let
>>     val arr = Primitive.Array.arrayUnsafe (a_length + b_length)
>> in
>>     string_concat_memmove(arr, a, a_length, b, b_length);
>>     Primitive.String8.idFromWord8Vector (Primitive.Vector.fromArrayUnsafe
>> arr)
>> end
>>
>> and got 20 times performance boost!
>
> Nice!  And is this implementation now faster than the Basis Library's
> implementation of String.^?  If so, then that is good evidence that we
> should invest in some kind of memmove-like primitive for copying data
> between sequences.  Doing it as a primitive with compiler/Basis
> Library support would allow us to use it for all kinds of sequences,
> so that it could speed up things like Vector.concat and Array.copy.

[Following up on an old thread; archive at:
https://sourceforge.net/p/mlton/mailman/mlton-user/thread/CAG%2BQnTcffmvXcpFv9rivvwdcsRXvUCorYVdEPmhjCE8EHEpOig%40mail.gmail.com/#msg35312358]

A memmove-like primitive for copying data between sequences has been
implemented, with promising results for large sequences (e.g.,
String.^), but incurs some small overhead for very small sequences.
See https://github.com/MLton/mlton/pull/192 for more details.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot