Thread overview
[Issue 9646] std.algorithm.splitter for strings has opportunities for improvement
Jun 28, 2016
qznc@web.de
Sep 07, 2016
Jack Stouffer
Mar 30, 2018
Seb
Dec 17, 2022
Iain Buclaw
June 02, 2016
https://issues.dlang.org/show_bug.cgi?id=9646

--- Comment #2 from github-bugzilla@puremagic.com ---
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/a9d5b8ca779d2dd89c8b49abae385e793d469e5d Improve speed of find for random access needles (strings)

For find a string within a string, std.algorithm.searching.find was unnecessarily slow. The reason is it created intermediate slices. A naively written nested-for-loop implementation was a few times faster.

For random access ranges (which strings are) this uses an index based algorithm, which does not need to create an intermediate slice. Speed is now comparable to the nested-for-loop implementation even in rather pathological cases.

This might help with issue 9646.

--
June 28, 2016
https://issues.dlang.org/show_bug.cgi?id=9646

qznc@web.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qznc@web.de

--- Comment #3 from qznc@web.de ---
For an update. This is still an issue for LDC 1.0.0 and DMD 2.071.0.

One problem is certainly that find does not get inlined. While everything of MySplitter gets inlined. Maybe this is more of a dmd than a phobos bug.

Does LDC use the LLVM inliner?

--
September 07, 2016
https://issues.dlang.org/show_bug.cgi?id=9646

Jack Stouffer <jack@jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |performance
                 CC|                            |jack@jackstouffer.com

--
October 01, 2016
https://issues.dlang.org/show_bug.cgi?id=9646

--- Comment #4 from github-bugzilla@puremagic.com ---
Commit pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/a9d5b8ca779d2dd89c8b49abae385e793d469e5d Improve speed of find for random access needles (strings)

--
March 30, 2018
https://issues.dlang.org/show_bug.cgi?id=9646

Seb <greensunny12@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greensunny12@gmail.com

--- Comment #5 from Seb <greensunny12@gmail.com> ---
New numbers:

DMD (2.079.0):

std.algorithm.splitter took 2 secs, 736 ms, 348 μs, and 3 hnsecs MySplitter took 3 secs, 176 ms, 18 μs, and 9 hnsecs

LDC (1.8.0):

>  ldc -O4 -mcpu=native -release -flto=full

std.algorithm.splitter took 1 sec, 954 ms, 444 μs, and 9 hnsecs MySplitter took 1 sec, 635 ms, 394 μs, and 8 hnsecs

So I there's still an opportunity for improvement with LDC.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=9646

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--