Implement PCRE2 JIT compilation#12866
Conversation
8ee722e to
b784413
Compare
b784413 to
5dd4ddf
Compare
| # can't be any concurrent access to the JIT stack. | ||
| @[ThreadLocal] | ||
| class_getter jit_stack : LibPCRE2::JITStack do | ||
| jit_stack = LibPCRE2.jit_stack_create(32_768, 1_048_576, Regex::PCRE2.general_context) |
There was a problem hiding this comment.
Maybe for a follow up, but these magic numbers could be or'ed with the ENV in order to have some control. I'm thinking in particular of memory-restricted apps.
| when .jit_badoption? | ||
| # okay | ||
| else | ||
| raise ArgumentError.new("Regex JIT compile error: #{error}") |
There was a problem hiding this comment.
Isn't this a bit too harsh? Without compilation the application might still work, even if slow. This said, I'm not sure how could we let the user know that something went wrong.
There was a problem hiding this comment.
I'm not sure what errors can actually reasonably appear here. When JIT compilation is not supported, that's indicated by ERROR_JIT_BADOPTION and handled in the previous branch (we ignore that).
Anything else, I don't know. But I would probably expect that could be more fatal errors where you may not be able to just continue on.
A more plausible point for ignoring errors might be when JIT stack allocation fails (jit_stack_create).
There was a problem hiding this comment.
PCRE2_ERROR_NOMEMORY is another one we might want to not raise. I wonder if it makes sense to just ignore any error and have a @compiled : Bool to know if it was compiled or not
Adds JIT support to the PCRE2 engine introduced in #12856.