Get rid of remaining FIXMEs in the code; implement JIT compile timing.
This commit is contained in:
parent
69985f7b9b
commit
adc7be2d3a
|
@ -160,10 +160,11 @@ Behave as if each subject line contains the given modifiers.
|
|||
.TP 10
|
||||
\fB-t\fP
|
||||
Run each compile and match many times with a timer, and output the resulting
|
||||
times per compile or match. You can control the number of iterations that are
|
||||
used for timing by following \fB-t\fP with a number (as a separate item on the
|
||||
command line). For example, "-t 1000" iterates 1000 times. The default is to
|
||||
iterate 500,000 times.
|
||||
times per compile or match. When JIT is used, separate times are given for the
|
||||
initial compile and the JIT compile. You can control the number of iterations
|
||||
that are used for timing by following \fB-t\fP with a number (as a separate
|
||||
item on the command line). For example, "-t 1000" iterates 1000 times. The
|
||||
default is to iterate 500,000 times.
|
||||
.TP 10
|
||||
\fB-tm\fP
|
||||
This is like \fB-t\fP except that it times only the matching phase, not the
|
||||
|
|
|
@ -7734,10 +7734,6 @@ re->top_bracket = cb.bracount;
|
|||
re->top_backref = cb.top_backref;
|
||||
re->max_lookbehind = cb.max_lookbehind;
|
||||
|
||||
#ifdef FIXME /* Is this necessary? Set above */
|
||||
re->flags = cb.external_flags | PCRE2_MODE;
|
||||
#endif
|
||||
|
||||
if (cb.had_accept)
|
||||
{
|
||||
reqcu = 0; /* Must disable after (*ACCEPT) */
|
||||
|
|
|
@ -3103,25 +3103,11 @@ if (re == NULL || subject == NULL || workspace == NULL || match_data == NULL)
|
|||
if (wscount < 20) return PCRE2_ERROR_DFA_WSSIZE;
|
||||
if (start_offset > length) return PCRE2_ERROR_BADOFFSET;
|
||||
|
||||
/* FIXME: Remove BADENDIANNESS if saving/restoring is not to be implemented. */
|
||||
|
||||
/* Check that the first field in the block is the magic number. If it is not,
|
||||
return with PCRE2_ERROR_BADMAGIC. */
|
||||
|
||||
if (re->magic_number != MAGIC_NUMBER) return PCRE2_ERROR_BADMAGIC;
|
||||
|
||||
#ifdef FIXME
|
||||
If saving restoring gets implemented, define PCRE2_ERROR_BADENDIANNESS, and add
|
||||
this comment and code:
|
||||
|
||||
/* However, if the magic number is equal to REVERSED_MAGIC_NUMBER we return
|
||||
with PCRE2_ERROR_BADENDIANNESS, which means that the pattern is likely compiled
|
||||
with different endianness. */
|
||||
|
||||
return re->magic_number == REVERSED_MAGIC_NUMBER?
|
||||
PCRE2_ERROR_BADENDIANNESS:PCRE2_ERROR_BADMAGIC;
|
||||
#endif
|
||||
|
||||
/* Check the code unit width. */
|
||||
|
||||
if ((re->flags & PCRE2_MODE_MASK) != PCRE2_CODE_UNIT_WIDTH/8)
|
||||
|
|
|
@ -82,8 +82,6 @@ Returns: > 0 => success; value is the number of ovector pairs filled
|
|||
< -1 => some kind of unexpected problem
|
||||
*/
|
||||
|
||||
/* FIXME: this is currently a placeholder function */
|
||||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_jit_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length,
|
||||
PCRE2_SIZE start_offset, uint32_t options, pcre2_match_data *match_data,
|
||||
|
|
|
@ -6412,18 +6412,6 @@ if (start_offset > length) return PCRE2_ERROR_BADOFFSET;
|
|||
|
||||
if (re->magic_number != MAGIC_NUMBER) return PCRE2_ERROR_BADMAGIC;
|
||||
|
||||
#ifdef FIXME
|
||||
If saving restoring gets implemented, define PCRE2_ERROR_BADENDIANNESS, and add
|
||||
this comment and code:
|
||||
|
||||
/* However, if the magic number is equal to REVERSED_MAGIC_NUMBER we return
|
||||
with PCRE2_ERROR_BADENDIANNESS, which means that the pattern is likely compiled
|
||||
with different endianness. */
|
||||
|
||||
return re->magic_number == REVERSED_MAGIC_NUMBER?
|
||||
PCRE2_ERROR_BADENDIANNESS:PCRE2_ERROR_BADMAGIC;
|
||||
#endif
|
||||
|
||||
/* Check the code unit width. */
|
||||
|
||||
if ((re->flags & PCRE2_MODE_MASK) != PCRE2_CODE_UNIT_WIDTH/8)
|
||||
|
|
|
@ -110,18 +110,6 @@ return with PCRE2_ERROR_BADMAGIC. */
|
|||
|
||||
if (re->magic_number != MAGIC_NUMBER) return PCRE2_ERROR_BADMAGIC;
|
||||
|
||||
#ifdef FIXME
|
||||
If saving restoring gets implemented, define PCRE2_ERROR_BADENDIANNESS, and add
|
||||
this comment and code:
|
||||
|
||||
/* However, if the magic number is equal to REVERSED_MAGIC_NUMBER we return
|
||||
with PCRE2_ERROR_BADENDIANNESS, which means that the pattern is likely compiled
|
||||
with different endianness. */
|
||||
|
||||
return re->magic_number == REVERSED_MAGIC_NUMBER?
|
||||
PCRE2_ERROR_BADENDIANNESS:PCRE2_ERROR_BADMAGIC;
|
||||
#endif
|
||||
|
||||
/* Check that this pattern was compiled in the correct bit mode */
|
||||
|
||||
if ((re->flags & (PCRE2_CODE_UNIT_WIDTH/8)) == 0) return PCRE2_ERROR_BADMODE;
|
||||
|
|
|
@ -651,6 +651,7 @@ static int timeit = 0;
|
|||
static int timeitm = 0;
|
||||
|
||||
clock_t total_compile_time = 0;
|
||||
clock_t total_jit_compile_time = 0;
|
||||
clock_t total_match_time = 0;
|
||||
|
||||
static uint32_t dfa_matched;
|
||||
|
@ -3933,23 +3934,22 @@ if ((pat_patctl.control & CTL_HEXPAT) == 0) patlen = PCRE2_ZERO_TERMINATED;
|
|||
if (timeit > 0)
|
||||
{
|
||||
register int i;
|
||||
clock_t time_taken;
|
||||
clock_t start_time = clock();
|
||||
clock_t time_taken = 0;
|
||||
for (i = 0; i < timeit; i++)
|
||||
{
|
||||
clock_t start_time = clock();
|
||||
PCRE2_COMPILE(compiled_code, pbuffer, patlen,
|
||||
pat_patctl.options|forbid_utf, &errorcode, &erroroffset, pat_context);
|
||||
time_taken += clock() - start_time;
|
||||
if (TEST(compiled_code, !=, NULL))
|
||||
{ SUB1(pcre2_code_free, compiled_code); }
|
||||
}
|
||||
total_compile_time += (time_taken = clock() - start_time);
|
||||
total_compile_time += time_taken;
|
||||
fprintf(outfile, "Compile time %.4f milliseconds\n",
|
||||
(((double)time_taken * 1000.0) / (double)timeit) /
|
||||
(double)CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
/* FIXME: implement timing for JIT compile. */
|
||||
|
||||
/* A final compile that is used "for real". */
|
||||
|
||||
PCRE2_COMPILE(compiled_code, pbuffer, patlen, pat_patctl.options|forbid_utf,
|
||||
|
@ -3974,11 +3974,35 @@ if (TEST(compiled_code, ==, NULL))
|
|||
if (pattern_info(PCRE2_INFO_MAXLOOKBEHIND, &maxlookbehind, FALSE) != 0)
|
||||
return PR_ABEND;
|
||||
|
||||
/* Call the JIT compiler if requested. */
|
||||
/* Call the JIT compiler if requested. When timing, we must free and recompile
|
||||
the pattern each time because that is the only way to free the JIT compiled
|
||||
code. We know that compilation will always succeed. */
|
||||
|
||||
if (pat_patctl.jit != 0)
|
||||
{
|
||||
PCRE2_JIT_COMPILE(compiled_code, pat_patctl.jit);
|
||||
if (timeit > 0)
|
||||
{
|
||||
register int i;
|
||||
clock_t time_taken = 0;
|
||||
for (i = 0; i < timeit; i++)
|
||||
{
|
||||
clock_t start_time;
|
||||
SUB1(pcre2_code_free, compiled_code);
|
||||
PCRE2_COMPILE(compiled_code, pbuffer, patlen,
|
||||
pat_patctl.options|forbid_utf, &errorcode, &erroroffset, pat_context);
|
||||
start_time = clock();
|
||||
PCRE2_JIT_COMPILE(compiled_code, pat_patctl.jit);
|
||||
time_taken += clock() - start_time;
|
||||
}
|
||||
total_jit_compile_time += time_taken;
|
||||
fprintf(outfile, "JIT compile %.4f milliseconds\n",
|
||||
(((double)time_taken * 1000.0) / (double)timeit) /
|
||||
(double)CLOCKS_PER_SEC);
|
||||
}
|
||||
else
|
||||
{
|
||||
PCRE2_JIT_COMPILE(compiled_code, pat_patctl.jit);
|
||||
}
|
||||
}
|
||||
|
||||
/* Output code size and other information if requested. */
|
||||
|
@ -6290,14 +6314,20 @@ if (INTERACTIVE(infile)) fprintf(outfile, "\n");
|
|||
|
||||
if (showtotaltimes)
|
||||
{
|
||||
const char *pad = "";
|
||||
fprintf(outfile, "--------------------------------------\n");
|
||||
if (timeit > 0)
|
||||
{
|
||||
fprintf(outfile, "Total compile time %.4f milliseconds\n",
|
||||
(((double)total_compile_time * 1000.0) / (double)timeit) /
|
||||
(double)CLOCKS_PER_SEC);
|
||||
if (total_jit_compile_time > 0)
|
||||
fprintf(outfile, "Total JIT compile %.4f milliseconds\n",
|
||||
(((double)total_jit_compile_time * 1000.0) / (double)timeit) /
|
||||
(double)CLOCKS_PER_SEC);
|
||||
pad = " ";
|
||||
}
|
||||
fprintf(outfile, "Total match time %.4f milliseconds\n",
|
||||
fprintf(outfile, "Total match time %s%.4f milliseconds\n", pad,
|
||||
(((double)total_match_time * 1000.0) / (double)timeitm) /
|
||||
(double)CLOCKS_PER_SEC);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue