Skip to content

Commit

Permalink
libast/regex: do not use small block size for stack (re: e311f1e)
Browse files Browse the repository at this point in the history
Opening the match stack with the STK_SMALL flag causes the stk code
to allocate memory in blocks of 64*sizeof(char*) instead of
1024*sizeof(char*). This caused a significant slowdown which was
exposed by the extglob.ksh module of shbench. Thanks to @JohnoKing
for noticing and reporting the problem.

src/lib/libast/regex/regcomp.c: regcomp():
- Remove STK_SMALL from the stkopen() option bit flags.

Resolves: ksh93/ksh#440
  • Loading branch information
McDutchie committed Jan 28, 2022
1 parent 9b4891a commit e38cd60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/libast/regex/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,7 @@ regcomp(regex_t* p, const char* pattern, regflags_t flags)
if (!(p->env = (Env_t*)alloc(disc, 0, sizeof(Env_t))))
return fatal(disc, REG_ESPACE, pattern);
memset(p->env, 0, sizeof(*p->env));
if (!(p->env->mst = stkopen(STK_SMALL|STK_NULL)))
if (!(p->env->mst = stkopen(STK_NULL)))
return fatal(disc, REG_ESPACE, pattern);
memset(&env, 0, sizeof(env));
env.regex = p;
Expand Down

0 comments on commit e38cd60

Please sign in to comment.