15:34, August 12, 2022, Gregory Heytings <gregory@heytings.org>:
 I've pushed a branch scratch/font_lock_large_files.


Thank you. But as I told you earlier, what that branch contains is a too
local fix.

Please read the rest of the message and the patch itself.

The new user option showcases different approaches to handling font-lock in very big files.

You created a new minimal major mode to edit JSON files, in
which you removed everything that made font locking slow in js-mode. As a
consequence, now editing the dictionary.json file is indeed reasonably
fast without disabling font locking or using locked narrowing

And yet, I'm yet to hear the applause.

You are referring to the changes on master, BTW.

I have eliminated two performance problems frim js-json-mode that are uncharacteristic for font-lock in general. One used a pathological matcher (simply removed), and another uses the "frameworks" facility which simply always rescans the full buffer from the beginning. That one can/should be fixed later, but I have disabled it for JSON (where it doesn't make sense anyway).

You should know that the rest of js-mode's font-lock keywords are still there. I experimented with leaving just the bare minimum needed for JSON, but the effect was very minimal (like 20% improvement).

(although it
is still too slow to my taste for larger files, e.g. I have to wait five
seconds after M-> in a ten times larger JSON file). And the original
problem is still present if you edit, for example, a 20 MB minified
JavaScript file...

Hence the new user option.

As for JS, you can also disable the frameworks thingy, manually. Until someone spends time on improving its caching strategy.