(setq gc-cons-threshold (\* 100 1024 1024) ;; GC sometime after allocating 100Mb
read-process-output-max (\* 1024 1024)
company-idle-delay 0.0 ;; company completions should be fast
company-minimum-prefix-length 1
lsp-idle-delay 0.1) ;; clangd is fast
(run-with-idle-timer 2 t (lambda () (garbage-collect))) ;; Trigger a GC after 5s of idle time
This is something of a hack of course, but it works & memory is cheap. You might want to push the GC threshold back down after emacs startup - a GC that fires early is a GC that does less work per invocation & is therefore less likely to cause perceptible stutter.