In this example I made a string of 1000 lines This is a $test, and then typing on line 1000 becomes very slow:

The cpu profiler shows 65% goes to font-lock-fontify-region:

Does anybody know if there is a way to speed up the font locking?
Thanks a lot!