RE: [PHP-DEV] PCRE JIT stack size limit
| From: | Anatol Belski | Date: | Mon, 21 Mar 2016 21:44:42 +0000 |
| Subject: | RE: [PHP-DEV] PCRE JIT stack size limit | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91828@lists.php.net to get a copy of this message | ||
Hi,
> -----Original Message-----
> From: Nikita Popov [mailto:nikita.ppv@gmail.com]
> Sent: Monday, March 21, 2016 7:54 PM
> To: Anatol Belski <anatol.php@belski.net>
> Cc: David Zuelke <dz@heroku.com>; Christoph Becker <cmbecker69@gmx.de>;
> Pierre Joye <pierre.php@gmail.com>; PHP internals <internals@lists.php.net>
> Subject: Re: [PHP-DEV] PCRE JIT stack size limit
>
> The issue I have with more increasing the stack is that - while as we see
> till today
> the default stack size of 32K is enough in the common case, the max of
> it
> will be
> reserved. So the real usage will most likely stay under 32K, but the
> whole
> of max
> (say 64K now) will be unusable by anything else.
>
>
>
> Are you sure about that? The documentation says "The arguments are a starting
> size for the stack, and a maximum size to which it is allowed to grow." Unless
> I'm misunderstanding something, it should not be allocating the maximum size
> right away.
>
Regarding PCRE it nearest refers to the point 2 of http://www.pcre.org/original/doc/html/pcrejit.html#SEC9
. The max we pass will turn to a reserved memory region. That means that the address space will be
not available for allocations within the same process/thread. Checking the PCRE code, that's
exactly what happens. A contiguous memory region gets claimed, but only the start size is being
allocated initially.
True is, that the memory usage will stay by the default stack size in the most cases, and currently
no issues are seen within the common app usage. But the reserved memory region will keep other
parts of the process out from taking the addresses inside it. This can cause negative impacts on
other PHP parts which could require some contiguous memory region, or on a general process memory
fragmentation. The more PCRE would reserve, the more addresses would be unavailable because of it.
Understanding that it is the nature of the PCRE JIT, we should keep our max value of the PCRE JIT
stack size as low as possible.
Regards
Anatol