Re: Deferring native compilation finalization until idle

Eli Zaretskii <[email protected]> Sat, 25 Jul 2026 10:28:14 +0300
Newsgroups gmane.emacs.devel
Message-ID <[email protected]>
> mail-alias-created-date: 1604598926000
> From: Perry Fraser <[email protected]>
> Cc: chad <[email protected]>,  [email protected],  [email protected],
>   [email protected],  [email protected]
> Date: Fri, 24 Jul 2026 21:51:47 -0400
> 
> Eli Zaretskii <[email protected]> writes:
> 
> > It's too specific to a single platform and a specific system, IMO.
> > That doesn't clear the threshold for being the default, or even an
> > opt-in feature.  So no, not worth the trouble, IMO.
> 
> I've used Emacs on macOS with native compilation for years and I always assumed that hanging during native compilation was the norm. I suspect many people are in the same boat here, and I have a feeling this affects just about everyone on macOS, which I would hope is enough to justify a patch.

There's no hanging.  The JIT native-compilation is run in a separate
process, which is asynchronous to the main Emacs process.  So if you
see any hang-like behavior, or "hiccups", I can only explain them by
your system having insufficient CPU resources for handling the
asynchronous processes without a visible performance degradation.  If
that is the root cause, I can suggest fiddling with the value of
native-comp-async-jobs-number.  Its default value of zero means Emacs
will launch as many async compilation jobs as half the number of
execution units your system has.  You can try using values that are
smaller, like 1 or 2, to control how many async compilation jobs are
launched concurrently.

> When using my normal config and attempting to edit my init file with a clear cache I get about a ten second hang. Using the patch added to etc/PROBLEMS completely alleviates the problem and is a /massive/ improvement.

If that is what solves the problem for you, then it is something
specific to macOS and completely unrelated to JIT compilation: it is
due to macOS validation of a shared library when it is first loaded.
That's why we added that item to PROBLEMS, and if that is the solution
for you, I don't really understand what you are asking us to do more
here.