www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12069] New: ctRegex is 3x slower then R-T ?

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069

           Summary: ctRegex is 3x slower then R-T ?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-02-03
11:14:04 PST ---
On behalf of Walter Bright, the benchmark:

import std.datetime;
import std.stdio;
import std.regex;

void ct()
{
    string phone = "+31 650 903 7158";
    //auto phoneReg = regex(r"^\+([1-9][0-9]*) [0-9 ]*$");
    static phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";
    auto m = match(phone, phoneReg);
    assert(m);
    assert(m.captures[0] == "+31 650 903 7158");
    assert(m.captures[1] == "31");
}

void rt()
{
    string phone = "+31 650 903 7158";
    auto phoneReg = regex(r"^\+([1-9][0-9]*) [0-9 ]*$");
    //static phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";
    auto m = match(phone, phoneReg);
    assert(m);
    assert(m.captures[0] == "+31 650 903 7158");
    assert(m.captures[1] == "31");
}

void main()
{
    auto r = benchmark!(ct, rt)(1_000_000);
    writefln("ct = %s msecs, rt = %s", r[0].msecs, r[1].msecs);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069



--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-02-03
11:19:09 PST ---
And a sample run:
C:\cbx\mars>dmd foo -O -release -inline -noboundscheck
C:\cbx\mars>foo
ct = 6281 msecs, rt = 1984

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-02-03
11:51:46 PST ---
https://github.com/D-Programming-Language/phobos/pull/1906

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2014-02-03
12:22:09 PST ---
Should also add this benchmark code to:

http://dlang.org/regular-expression.html

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069



--- Comment #4 from github-bugzilla puremagic.com 2014-02-03 13:50:01 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b64c0919162a2bb9ac730f6f3980fe527c1bc9e0
fix issue 12069

On Win32 allocating large blocks (>512K) is forwarded to
VirtualAlloc/VirtualFree. Doing these calls is expensive especially in a
loop. As a temporary solution a block size of a segmented stack is
decreased to ~1/8 of critical size.

The code needs to be adapted once allocators are in std.

https://github.com/D-Programming-Language/phobos/commit/908908164cbcf3fb6690912b155cd133c4861392
Merge pull request #1906 from blackwhale/issue-12069

Fix issue 12069

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069



--- Comment #5 from github-bugzilla puremagic.com 2014-02-03 15:20:12 PST ---
Commit pushed to 2.065 at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/f1eadb913608ad1e1acd800e6c36b2b50b2a9f12
Merge pull request #1906 from blackwhale/issue-12069

Fix issue 12069

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-02-04
01:02:33 PST ---
Closed, updating the article is worth a bug report on its own.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12069



--- Comment #7 from github-bugzilla puremagic.com 2014-02-27 20:13:18 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/f1eadb913608ad1e1acd800e6c36b2b50b2a9f12
Merge pull request #1906 from blackwhale/issue-12069

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2014