Could you paste the regex portion of it please? Possibly some efficiencies to be gained there. You could also split the file into smaller chunks and then check the boundaries of the chunks.
ripgrep should be able to handle it with the -U/--multiline flag.
Maybe some other PCRE-compatible implementation offers streaming. For instance, https://www.intel.com/content/www/us/en/developer/articles/t... says it has this feature, but of course given who it's from it may be tied to a single brand of CPU.
github seems to be https://github.com/intel/hyperscan