Subject: 29.0.50; Fontification is slow after e7b5912b23 (Improvements to long lines handling)
From: Ihor Radchenko <[email-masked]>
To: [email-masked]
Date: Sun, 14 Aug 2022 23:55:46 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

I am experiencing severe performance degradation on current master.

The degradation happens when working with Org files and I managed to
bisect the cause down to

e7b5912b235936b304701ba6b1e808d9b197fd4f is the first bad commit
commit e7b5912b235936b304701ba6b1e808d9b197fd4f
Author: Gregory Heytings <[email-masked]>
Date:   Sat Jul 16 19:06:38 2022 +0000

    Improvements to long lines handling.
    
    * src/buffer.h (struct buffer): New field 'long_line_optimizations_p'.
    
    * src/buffer.c (syms_of_buffer): New variable 'long-line-threshold'.
    (reset_buffer): Initialize the 'long_line_optimizations_p' field.
    (Fbuffer_swap_text): Handle it.
...

I tried M-x profiler to find the cause, but the 3-4 second hangs are not
reflected in the profiler report.

debug-on-entry + manual stepping through the function revealed that the
hang happens when calling jit-lock-fontify-now.

I was able to trigger the slowdown when unfolding headlines hidden using
'invisible text property.

Do you have any idea what could be going wrong or how to debug things further?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92