version 1.1.1.1, 2012/02/21 23:05:51
|
version 1.1.1.3, 2012/10/09 09:19:17
|
Line 1
|
Line 1
|
.TH PCREPERFORM 3 | .TH PCREPERFORM 3 "09 January 2012" "PCRE 8.30" |
.SH NAME |
.SH NAME |
PCRE - Perl-compatible regular expressions |
PCRE - Perl-compatible regular expressions |
.SH "PCRE PERFORMANCE" |
.SH "PCRE PERFORMANCE" |
Line 11 of them.
|
Line 11 of them.
|
.SH "COMPILED PATTERN MEMORY USAGE" |
.SH "COMPILED PATTERN MEMORY USAGE" |
.rs |
.rs |
.sp |
.sp |
Patterns are compiled by PCRE into a reasonably efficient byte code, so that | Patterns are compiled by PCRE into a reasonably efficient interpretive code, so |
most simple patterns do not use much memory. However, there is one case where | that most simple patterns do not use much memory. However, there is one case |
the memory usage of a compiled pattern can be unexpectedly large. If a | where the memory usage of a compiled pattern can be unexpectedly large. If a |
parenthesized subpattern has a quantifier with a minimum greater than 1 and/or |
parenthesized subpattern has a quantifier with a minimum greater than 1 and/or |
a limited maximum, the whole subpattern is repeated in the compiled code. For |
a limited maximum, the whole subpattern is repeated in the compiled code. For |
example, the pattern |
example, the pattern |
Line 34 example, the very simple pattern
|
Line 34 example, the very simple pattern
|
.sp |
.sp |
((ab){1,1000}c){1,3} |
((ab){1,1000}c){1,3} |
.sp |
.sp |
uses 51K bytes when compiled. When PCRE is compiled with its default internal | uses 51K bytes when compiled using the 8-bit library. When PCRE is compiled |
pointer size of two bytes, the size limit on a compiled pattern is 64K, and | with its default internal pointer size of two bytes, the size limit on a |
this is reached with the above pattern if the outer repetition is increased | compiled pattern is 64K data units, and this is reached with the above pattern |
from 3 to 4. PCRE can be compiled to use larger internal pointers and thus | if the outer repetition is increased from 3 to 4. PCRE can be compiled to use |
handle larger compiled patterns, but it is better to try to rewrite your | larger internal pointers and thus handle larger compiled patterns, but it is |
pattern to use less memory if you can. | better to try to rewrite your pattern to use less memory if you can. |
.P |
.P |
One way of reducing the memory usage for such patterns is to make use of PCRE's |
One way of reducing the memory usage for such patterns is to make use of PCRE's |
.\" HTML <a href="pcrepattern.html#subpatternsassubroutines"> |
.\" HTML <a href="pcrepattern.html#subpatternsassubroutines"> |
Line 68 that PCRE cannot otherwise handle.
|
Line 68 that PCRE cannot otherwise handle.
|
.SH "STACK USAGE AT RUN TIME" |
.SH "STACK USAGE AT RUN TIME" |
.rs |
.rs |
.sp |
.sp |
When \fBpcre_exec()\fP is used for matching, certain kinds of pattern can cause | When \fBpcre_exec()\fP or \fBpcre16_exec()\fP is used for matching, certain |
it to use large amounts of the process stack. In some environments the default | kinds of pattern can cause it to use large amounts of the process stack. In |
process stack is quite small, and if it runs out the result is often SIGSEGV. | some environments the default process stack is quite small, and if it runs out |
This issue is probably the most frequently raised problem with PCRE. Rewriting | the result is often SIGSEGV. This issue is probably the most frequently raised |
your pattern can often help. The | problem with PCRE. Rewriting your pattern can often help. The |
.\" HREF |
.\" HREF |
\fBpcrestack\fP |
\fBpcrestack\fP |
.\" |
.\" |
Line 101 character classes such as [:alpha:] do not use Unicode
|
Line 101 character classes such as [:alpha:] do not use Unicode
|
backwards compatibility, and partly for performance reasons. However, you can |
backwards compatibility, and partly for performance reasons. However, you can |
set PCRE_UCP if you want Unicode character properties to be used. This can |
set PCRE_UCP if you want Unicode character properties to be used. This can |
double the matching time for items such as \ed, when matched with |
double the matching time for items such as \ed, when matched with |
\fBpcre_exec()\fP; the performance loss is less with \fBpcre_dfa_exec()\fP, and | a traditional matching function; the performance loss is less with |
in both cases there is not much difference for \eb. | a DFA matching function, and in both cases there is not much difference for |
| \eb. |
.P |
.P |
When a pattern begins with .* not in parentheses, or in parentheses that are |
When a pattern begins with .* not in parentheses, or in parentheses that are |
not the subject of a backreference, and the PCRE_DOTALL option is set, the |
not the subject of a backreference, and the PCRE_DOTALL option is set, the |
Line 172 Cambridge CB2 3QH, England.
|
Line 173 Cambridge CB2 3QH, England.
|
.rs |
.rs |
.sp |
.sp |
.nf |
.nf |
Last updated: 16 May 2010 | Last updated: 09 January 2012 |
Copyright (c) 1997-2010 University of Cambridge. | Copyright (c) 1997-2012 University of Cambridge. |
.fi |
.fi |