www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12394] New: Regression: std.regex unittests take agonizingly long to run - like hours on OSX

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

           Summary: Regression: std.regex unittests take agonizingly long
                    to run - like hours on OSX
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla digitalmars.com


--- Comment #0 from Walter Bright <bugzilla digitalmars.com> 2014-03-17
18:45:52 PDT ---
The diff with one that runs in a reasonable length of time is:
----------------------------
3931,3934c3931,3934
<     CtContext lookaround()
<     {
<         CtContext ct;
<         ct.total_matches = total_matches;
---
     CtContext lookaround(uint s, uint e)
     {
         CtContext ct;
         ct.total_matches = e - s;

< CtContext context = lookaround(); //split off new context ---
             CtContext context = lookaround(ir[1].raw, ir[2].raw); //split off
new context

             auto altCode = testCode.length ? ctSub("else goto case $$;",
fixup) : "";

< else < goto case $$; < case $$://restore state and go inside loop < $$ < goto case $$;`, curInfLoop, addr+2, curInfLoop, < testCode, saveCode(addr+1), < addr+2, fixup, addr+1, restoreCode(), fixup); ---
                     $$
                 case $$://restore state and go inside loop
                     $$
                     goto case $$;`, curInfLoop, addr+2, 
                     curInfLoop, testCode, saveCode(addr+1),
                     addr+2, altCode, addr+1, restoreCode(), fixup);

< matcher.re.ngroup = re.ir[t.pc+2].raw - re.ir[t.pc+1].raw; < matcher.backrefed = backrefed.empty ? t.matches : backrefed; < //backMatch < bool nomatch = (matcher.matchOneShot(t.matches, IRL!(IR.LookbehindStart)) < == MatchResult.Match) ^ positive; < freelist = matcher.freelist; < subCounters[t.pc] = matcher.genCounter; < if(nomatch) ---
                 matcher.re.ngroup = me - ms;
                 matcher.backrefed = backrefed.empty ? t.matches : backrefed;
                 //backMatch
                 auto mRes = matcher.matchOneShot(t.matches.ptr[ms .. me],
IRL!(IR.LookbehindStart));
                 freelist = matcher.freelist;
                 subCounters[t.pc] = matcher.genCounter;
                 if((mRes == MatchResult.Match) ^ positive)

< bool nomatch = (matcher.matchOneShot(t.matches, IRL!(IR.LookaheadStart)) < == MatchResult.Match) ^ positive; ---
                 auto mRes = matcher.matchOneShot(t.matches.ptr[ms .. me],
IRL!(IR.LookaheadStart));

< if(nomatch) ---
                 if((mRes == MatchResult.Match) ^ positive)

< t.pc = re.ir[t.pc].indexOfPair(t.pc); < uint ms = re.ir[t.pc+1].raw, me = re.ir[t.pc+2].raw; < finish(t, matches.ptr[ms..me]); ---
                 finish(t, matches.ptr[0 .. re.ngroup]);

< assert(c.pre == " "); // Part of input preceeding match ---
     assert(c.pre == " "); // Part of input preceding match

 // bugzilla 12076
 unittest
 {
     auto RE = ctRegex!(r"(?<!x\w+)\s(\w+)");
     string s = "one two";
     auto m = match(s, RE);
 }
 
 // bugzilla 12105
 unittest
 {
     auto r = ctRegex!`.*?(?!a)`;
     assert("aaab".matchFirst(r).hit == "aaa");
     auto r2 = ctRegex!`.*(?!a)`;
     assert("aaab".matchFirst(r2).hit == "aaab");
 }
 

It happens on my OSX machine, possibly because it doesn't have that much memory and is swapping itself to death. But unittests need to run in a reasonable amount of time or people won't run them at all. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 17 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12394


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com


--- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-03-18
01:39:26 PDT ---
I bet CTFE puts pressure on RAM and that Mac machine doesn't have that much.

Looking at fresh unittests below, try changing:

// bugzilla 12076
...

auto RE = ctRegex!(r"(?<!x\w+)\s(\w+)");

To 

auto RE =  ctRegex!(r"(?<!x[a-z]+)\s([a-z]+)");

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