Re: Some regular-expression performance hacking

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2021-02-23T17:52:28Z
Lists: pgsql-hackers
I wrote:
> Hmph.  There's an "assert(depth >= 0)" immediately in front of that,
> so I'm not looking too kindly on the compiler thinking it's smarter
> than I am.  Do you have a suggestion on how to shut it up?

On reflection, maybe the thing to do is convert the assert into
an always-on check, "if (depth < 0) return false".  The assertion
is essentially saying that there's no arc leading directly from
the pre state to the post state.  Which there had better not be,
or a lot of other stuff is going to go wrong; but I suppose there's
no way to explain that to gcc.  It is annoying to have to expend
an always-on check for a can't-happen case, though.

			regards, tom lane



Commits

  1. Suppress unnecessary regex subre nodes in a couple more cases.

  2. Improve memory management in regex compiler.

  3. Extend a test case a little

  4. Allow complemented character class escapes within regex brackets.

  5. Suppress compiler warning in new regex match-all detection code.

  6. Avoid generating extra subre tree nodes for capturing parentheses.

  7. Convert regex engine's subre tree from binary to N-ary style.

  8. Fix regex engine to suppress useless concatenation sub-REs.

  9. Recognize "match-all" NFAs within the regex engine.

  10. Invent "rainbow" arcs within the regex engine.

  11. Make some minor improvements in the regex code.

  12. Display the time when the process started waiting for the lock, in pg_locks, take 2

  13. README/C-comment: document GiST's NSN value

  14. doc: Mention NO DEPENDS ON EXTENSION in its supported ALTER commands