Air Date:
Latest update:
To combat a perceived sluggishness (compared to the Linux version),
you need to turn on 2 features: native compilation and
tree-sitter. Both are half-enabled: the support is compiled-in, but
they don't work properly without a suitable environment. The latter
you get automatically on any sensible Linux distro, while Windows
setup requires additional steps.
(There are no (setq w32-make-it-fast t) secret settings in this
post.)
Native compilation
Without it, Emacs is barely usable in any Windows 11 XXhY release. If
you don't switch this apparatus on, so to speak, then better forget
about Emacs, & move on to greener pastures.
It's hard to overstate how much JIT shakes things
up. The official .zip ships Lisp code that was natively compiled in
advance, so Emacs runs it at full speed, but can't necessarily
natively compile 3rd-party code. Hardly anyone uses Emacs in emacs -Q
fashion, hence without native-comp, installing any complex ELPA/Melpa
package means mediocre performance.
To get a sense of the irrelevant figures we are talking about here, take a look
at the graph of calculating a Fibonacci sequence in Elisp with &
without NC:

(A script that produced the numbers above.)
NC requires 2 things:
- libgccjit library.
- GCC compiler, linker & assembler.
Items 1 & 2 must come from roughly the same GCC version suite Emacs was compiled
with. Do you see a problem here? On Linux, a package manager installs
a compiler of a ~similar version to the one used to build other
packages, including Emacs. When a distro is in sync, everything works
automatically: libgccjit invokes the compiler with the corresponding
binutils tools, & Emacs happily runs code native to your CPU.
None of this is true by default in Windows.
First, after you download the .zip (or install the editor via
scoop, or whatever), you need to hunt down exactly which compiler was
used to make the Windows bundle.
ELISP> system-configuration
"x86_64-w64-mingw32"
gives us the type, but no version string. The only reliable way I found
was to look inside the executable:
powershell> strings emacs.exe | sls 'GCC: \(' | select -f 1
GCC: (Rev5, Built by MSYS2 project) 16.1.0
Second, you find that libgccjit-0.dll is missing. Meaning,
even though NC was technically enabled during the build, the car can't
move now, because its battery was nicked pulled out.
The Emacs repo contains some scripts presumably used to generate the
.zip, & one of them has the following soothing lines:
# libraries we never include
DLL_SKIP=["libgccjit-0.dll"]
For this particular Emacs 31.1, I manually fished out the dll from the
msys2 archive.
Third, you need to decide which mingw toolkit to get that would be
compatible with your libgccjit-0.dll. I downloaded a minimal
x86_64-16.1.0-release-posix-seh-ucrt-rt_v14-rev1 variant from
github.com/niXman. There has got to be an edition somewhere that
also contains libgccjit, but searching for one was too tedious.
Setup
The coveted libgccjit-0.dll gets loaded dynamically on start-up if
Emacs finds it. Keeping the dll next to emacs.exe works. (Modifying
dynamic-library-alist instead doesn't.) If Emacs refuses to load it
(test with native-comp-available-p function), get a
reimplementation of ldd for Windows, and check the dll for missing
dependencies.
Here comes a possible explanation of why libgccjit-0.dll isn't
shipped in the .zip: after the dll is loaded, Emacs convinces itself
that
ELISP> (native-comp-available-p)
t
and attempts to asynchronously compile installed 3rd-party code, while
simultaneously continuing to read your ~/.emacs config. If there is
no "compatible" gcc+as+ld can be found, the action fails with a scary error.
I decided against adding yet another compiler to PATH, & extracted the
mingw toolkit into ~/.emacs.d/windows. For that to work, we ought to
modify the env var only for Emacs & its children, & do it very early
in the editor's boot process:
> cat $env:APPDATA/.emacs.d/early-init.el
;; -*- lexical-binding: t; -*-
(let ((mingw (expand-file-name "~/.emacs.d/windows/mingw64/bin")))
(when (and (eq system-type 'windows-nt) (file-exists-p mingw))
(let ((paths (parse-colon-path (getenv "PATH"))))
(add-to-list 'paths mingw)
(setenv "PATH" (string-join (delq nil paths) path-separator))
(add-to-list 'exec-path mingw))))
(Why there is no standard (add-to-path STRING) function that itself
handles all the fiddling with the lists, I don't know.)
Now, when you start Emacs, it should silently begin JIT compilation
(the results are visible in ~/.emacs.d/eln-cache directory).
Tree-sitter
To enjoy some of those exciting new major modes everyone is talking
about, activate a special mapping from the "traditional" to the
"new":
(defun my-native-comp-available-p()
(and (executable-find "as") (native-comp-available-p)))
(when (my-native-comp-available-p)
(setq major-mode-remap-alist
'((mhtml-mode . mhtml-ts-mode)
(js-json-mode . json-ts-mode)
(ruby-mode . ruby-ts-mode)
(c-mode . c-ts-mode)))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-ts-mode)))
We check whether tree-sitter would even work (a more robust test would
include treesit-available-p & a lookup for the "git" executable),
because a compatible compiler toolchain is required as well.
It's rather pointless to set up tree-sitter without having native
compilation working. While they are orthogonal, they both employ the
same toolchain dependency.
Misc
Other niceties unrelated to performance:
scoop install gpg, otherwise M-x package-list-packages throws an
error;
- hunspell-windows
provides a bundle with mingw64 binaries & dictionaries extracted
from the Fedora repos.
Reroute to Linux
All of the above could also be a waste of time. No matter how much JIT
Emacs does, how hard it tries, NTFS with the NT I/O scheduler makes
anything involving lots of small processes & files choke like a snake
eating an elephant.
Instead, people suggest using WSL2, Emacs inside VMWare, or
carrying around an SBC:
LIBERTYPRIME_1776 1 point 2019-07-11
when i use emacs on windows i do it via a raspberry pi.
use it internet via ethernet to usb converter and use putty to connect
to it and run emacs, use TRAMP to modify stuff on windows.
-
The Elisp manual says "The resulting speedup … is usually 2.5 to 5
times faster than the corresponding byte-compiled code."
- That's a quote.
Tags: ойті
Authors: ag
Air Date:
Latest update:
London, 1851:
'The fried fish-sellers live in some out of the way alley, and not
unfrequently in garrets; for among even the poorest class there are
great objections to their being fellow-lodgers, on account of the
odour from the frying. Even when the fish is fresh (as it most
frequently is), and the oil pure, the odour is rank.
'In one place I visited, which was, moreover, admirable for
cleanliness, it was very rank. The cooks, however, whether husbands
or wives—for the women often attend to the pan—when they hear of
this disagreeable rankness, answer that it may be so, many people
say so; but for their parts they cannot smell it at all …
'None, or very few, of those who are their own cooks, reside at a
greater distance than three miles from Billingsgate. A gin-drinking
neighbourhood, one coster said, suits best, "for people hasn't
their smell so correct there."
'At the neighbouring races and fairs there is a great sale of fried
fish … At Epsom races there was plenty of bread, I was informed,
to be picked up on the ground; it had been flung from the carriages
after luncheon, and this, with a piece of fish, supplied a meal or
"a relish" to hundreds …
'The capital required to start properly in the business is:
- frying-pan 2s. (second-hand 9d.);
- tray 2s. 6d. (second-hand 8d.);
- salt-box 6d. (second-hand 1d.);
- and stock-money 5s.
—in all 10s. A man has gone into the trade, however, with 1s.,
which he expended in fish and oil, borrowed a frying-pan, borrowed
an old tea-board, and so started on his venture.'
(From London Labour and the London Poor, Vol. 1 by Henry Mayhew.)

Tags: quote, england
Authors: ag
Air Date:
Latest update:
For each version, starting with 9 (2017), Debian provides a big
ChangeLog file that lists fixes included in periodic updates. If one
looks at the changelog for the current release (13), the number of CVE
mentions may astonish an unsuspecting reader.
While I wasn't going to waste space here explaining the obvious reason
for such an explosion, I got curious about how it had changed over
time.
If we extract CVE names & group them by the dates on which they appear
in a file, like, for example, in v9:
2017-07-22 44
2017-10-07 348
2017-12-09 301
2018-03-10 280
2018-07-14 331
2018-11-10 766
2019-02-16 206
2019-04-27 214
2019-09-07 250
2020-02-08 424
2020-07-18 434
& do the same for all subsequent Debian versions, we get a quite
expected, but still dreadful, picture nevertheless:

(An archive with the data & scripts: debian-cve.tar.xz.)
Tags: ойті
Authors: ag