Hacker News new | past | comments | ask | show | jobs | submit login

Not sure that’s needed. Sending SIGSTOP (or using cgroup freeze) and letting the linux memory management do its job should do most of that already.



I've used this to speed-up CLI commands which have a slow startup phase. I run the process up to the point where it finishes initializing things and starts reading input, SIGSTOP there, and resume it later. You can identify that "reading input" library call with strace, and intercept it dynamically with an LD_PRELOAD shim.

I haven't yet figured out how to (neatly) persist this to disk, so I just sort of make a mini server-loop that catches signals and dispatches a fork() for each one, and that's my fast version of the CLI command. Delightfully ugly :)

(The killer app I'm trying to apply this to is LaTeX, so that I can write math notes in Emacs, incrementally, without visible latency. Unfortunately the running LaTeX process is slightly convoluted, and needs a few more tricks to get working in this way. This trick works on the plain TeX command out-of-the-box (it's like a 50x speedup), so I think I'm on the right track...)


> The killer app I'm trying to apply this to is LaTeX, so that I can write math notes in Emacs, incrementally, without visible latency.

See texpresso [1] for one solution that does something like this with the LaTeX process.

Another, more conservative solution is the upcoming changes to Org mode's LaTeX previews [2] which can preview live as you type, with no Emacs input lag (Demos [3,4]).

[1] https://github.com/let-def/texpresso

[2] https://abode.karthinks.com/org-latex-preview/

[3] http://tinyurl.com/olp-auto-1

[4] https://tinyurl.com/ms2ksthc


I wasn't aware of either of those, so thank you very much for those referrals I shall take a close look at :)

(Are you by chance the author of org-latex-preview, or is it a coincidence of usernames?)


I am one of the authors, should have mentioned. It's not part of Org yet, but should be some time this year.


Yes I confirm it works - I’ve been using this very behavior for years


Yep, nothing fancy needed




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: