in reply to Re^5: What perl operations will consume C stack space?
in thread What perl operations will consume C stack space?
On my system using 5.8.6, /(ab*){$n}/ cores with $n == 21166, whereas /(ab|a){$n}/ completes sucessfully for all values on $n upto the repetition limit of 32766. If I drop the stack reservation to 8 MB (similar to the default on Linux?), then I get a similar breakpoint of 10582.
That seems to indicate that (OMS), the regex engine requires 792 bytes of stack for each repetition. That seems a lot of state to preserve on the stack, but I know nothing about how the regex engine is implemented, so it's probably not.
It does make me wonder whether repetition counts, at least in these fairly simple cases, couldn't be fulfilled with by a tail recursive routine to alleviate the stack growth?
If not, isn't there some scope for putting a check of the form die 'Not enough stack' if reps > stacksize / 792?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: What perl operations will consume C stack space?
by hv (Prior) on Feb 27, 2006 at 18:53 UTC | |
by BrowserUk (Patriarch) on Feb 27, 2006 at 20:43 UTC |