<div dir="ltr"><div dir="ltr"><div dir="ltr">Took me a bit of looking, but the issue is in the details- the decision character for "stuff" is '-' since that is always the beginning of "ruler", the first regex under "control_2" which is the first regex following "stuff". Changing to "-" and re-ordering the stuff regex fixes the proof-of-concept, and speeds it up roughly 40% on my system.<div><br></div><div><div><font face="monospace">    regex stuff </font></div><div><font face="monospace">    {</font></div><div><font face="monospace">        [            # </font>stuff is a group of either</div><div><font face="monospace">            <-[-]>+: # </font>a ratcheting string of non-decision points. Removing ratcheting makes it hang on Yary's system.</div><div><font face="monospace">          ||         # </font>or</div><div><font face="monospace">            '-'      # </font>a "dash" decision point</div><div><font face="monospace">        ]*           # </font>0-many of those. Greedy or non-greedy both work, about the same speed.</div><div><font face="monospace">    }  #</font> end regex</div></div><div><br></div><div>Will commit this soon.</div><div><br></div><div>(and thanks for making this runnable & pointing out that I can use your test files all in the repo)</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature">-y<br></div></div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 29, 2021 at 8:07 PM Joseph Brenner <<a href="mailto:doomvox@gmail.com">doomvox@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">That's interesting thinking... I've been playing around with the idea<br>
over here, but haven't got it to work (it fails to parse):<br>
<br>
<a href="https://github.com/doomvox/raku-study/blob/main/bin/2021mar28/doomfiles_browse_sequence-iii.raku" rel="noreferrer" target="_blank">https://github.com/doomvox/raku-study/blob/main/bin/2021mar28/doomfiles_browse_sequence-iii.raku</a><br>
<br>
This version does work-- just using greedy matching on "stuff" makes<br>
it use orders-of-magnitude less resources:<br>
<br>
<a href="https://github.com/doomvox/raku-study/blob/main/bin/2021mar28/doomfiles_browse_sequence-ii.raku" rel="noreferrer" target="_blank">https://github.com/doomvox/raku-study/blob/main/bin/2021mar28/doomfiles_browse_sequence-ii.raku</a><br>
<br>
<br>
And yes, I would guess that the non-greedy matching probably works<br>
here because the following material is effectively pinned at the end<br>
of the document.<br>
<br>
Note that you should be able to run these scripts as written, provided<br>
you also pull copies of these source files:<br>
<br>
<a href="https://github.com/doomvox/raku-study/tree/main/dat/doomfiles" rel="noreferrer" target="_blank">https://github.com/doomvox/raku-study/tree/main/dat/doomfiles</a><br>
<br>
<br>
<br>
On 3/29/21, yary <<a href="mailto:not.com@gmail.com" target="_blank">not.com@gmail.com</a>> wrote:<br>
> Hi Joe & other Raku study group attendees,<br>
><br>
> At the time I left, we were looking at a grammar with a speed-memory issue<br>
> on large-ish files. I had a germ of an idea which I couldn't express, and<br>
> from the meeting notes I see you have a simple fix *"by changing stuff<br>
> regex (.\*?) to non-greedy (.\*)*" I suspect the greedy-optimization works<br>
> because the thing after the "stuff" regex is near the end of the file. Thus<br>
> if instead it was close to the beginning, it would have a similar issue<br>
> with greedy and non-greedy would fix.<br>
><br>
> With a night to sleep on it, the thing I was thinking & trying to say is<br>
> that, in the specialized HTML-grammar you had, the decision points are all<br>
> at left-brackets. By re-writing "stuff" so that it will only backtrack when<br>
> it hits a bracket, I expect more speed-memory gains.<br>
><br>
> How well does this perform vs the simple .* greedy fix?<br>
><br>
>     regex stuff<br>
>     { (  # capture stuff (positional capture might not be needed)<br>
>         [               # Stuff is a group of either<br>
>             \<          # a left-bracket decision point<br>
>           ||            # or<br>
>             <-[ \< ]>+: # a ratcheting string of non-decision points<br>
>         ]*              # 0-many of those. Greedy or non-greedy both work?<br>
>     ) }  # end capture, end regex<br>
><br>
> This was harder to express verbally & in code than I expected!<br>
><br>
> -y<br>
><br>
><br>
> On Sun, Mar 28, 2021 at 4:23 PM Joseph Brenner <<a href="mailto:doomvox@gmail.com" target="_blank">doomvox@gmail.com</a>> wrote:<br>
><br>
>> I did send this one out, but it doesn't seem that it went out exactly,<br>
>> so let's try this one more time.   The Study Group is happening,<br>
>> already in progress, though we'll be taking a break next week and<br>
>> broadcasting a burning yule log with the soundtrack to Jesus Christ<br>
>> Superstar.  (Just kidding)<br>
>><br>
>><br>
>> Flaming Carrot, "Night Patrol" (1986) by Bob Burden:<br>
>><br>
>>     I feel it rising now...<br>
>>     ... like little bubbles...<br>
>>     THE MOON IS FULL...<br>
>>     ... in a full moon, your brain floats to top of your head...<br>
>>     I feel it...<br>
>>     beginning to boil...<br>
>>     a lot will happen tonight.<br>
>><br>
>> The Raku Study Group<br>
>><br>
>> March 28, 2021  1pm in California, 8pm in the UK<br>
>><br>
>> Zoom meeting link:<br>
>><br>
>> <a href="https://us02web.zoom.us/j/81127128506?pwd=N0I5bkxUZTRLaWwxN2RJTGlsT254QT09" rel="noreferrer" target="_blank">https://us02web.zoom.us/j/81127128506?pwd=N0I5bkxUZTRLaWwxN2RJTGlsT254QT09</a><br>
>><br>
>> Passcode: 4RakuRoll<br>
>><br>
>> RSVPs are useful, though not needed:<br>
>>   <a href="https://www.meetup.com/San-Francisco-Perl/events/277163968/" rel="noreferrer" target="_blank">https://www.meetup.com/San-Francisco-Perl/events/277163968/</a><br>
>> _______________________________________________<br>
>> SanFrancisco-pm mailing list<br>
>> <a href="mailto:SanFrancisco-pm@pm.org" target="_blank">SanFrancisco-pm@pm.org</a><br>
>> <a href="https://mail.pm.org/mailman/listinfo/sanfrancisco-pm" rel="noreferrer" target="_blank">https://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br>
>><br>
><br>
</blockquote></div>