Skip to content
Discussion options

You must be logged in to vote

Thank you for the nice repro!

So the optimizations in play here are complicated and some patterns get different optimization strategies compared to others. That can make one regex compile longer than another. The baffling thing can be that, if you're not familiar with regex internals, it can be difficult to predict when optimization is in play. To debug this yourself in the future, you can enable the logging feature of regex, then use a crate like env_logger with the log level set to trace to get a bunch of details about regex compilation. For example, adapting your endswith case insensitive benchmark to use an input of 10, we get this:

[2025-10-30T13:11:03Z DEBUG regex_automata::meta::re…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BurntSushi
Comment options

@gsson
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants