TeXmacs Chez port (BETA)

I’ve merged the chez code into the wip_other_schemes branch, so now it sits on par with the other implementations. For the moment I’m not sure if I want to build versions of Upsilon with it. I guess it needs some more testing first.

A quick update: in the end I did build Upsilon with it :slightly_smiling_face:

  • The Chez port is now merged into Upsilon (branch upsilon_texmacs), next to s7, femtolisp and Guile. It’s still a build option, ./configure --with-scheme=chez; s7 remains the default. All 64 regression suites and the 50 startup checks pass on Chez, both in one process and with one process per suite.
  • There’s an experimental macOS package (Qt 6, Apple silicon, macOS 15 or later): texmacs-qt-chez-macos-arm64.zip among the latest builds, https://mgubi.org/texmacs/ (or the pre-release upsilon-latest). It’s “TeXmacs Upsilon Qt Chez.app” and installs next to the other Upsilon apps. It contains the compiled modules, the boot image and Chez’s own heap images, so Chez doesn’t need to be installed. The macOS CI now builds it, runs all the tests on it, and publishes it with the other packages.
  • The compiler is the one from Joy’s branch, with fixes so it handles the newer Upsilon code: about 140 more modules, the tree-sitter/LSP glue, a few more Guile/s7 compatibility functions, keywords in scripts, gc freeing the C++ objects, etc. A full compilation of all ~620 modules takes about 25 s here (23.5 s for the modules plus 2 s for the boot image); after editing a file only the changed modules are recompiled. The docs are in src/docs/chez.

Some numbers on an M-series Mac, all three builds from the same Upsilon code (Qt, offscreen):

s7 Chez Guile 1.8 (-O2)
startup 0.88 s 0.87 s 1.27 s
memory after startup 275 MB 355 MB 206 MB
LaTeX export of the change log, warm (avg of 8) 218 ms 58 ms 539 ms
same, cold 1147 ms 782 ms 1813 ms
4 test suites (latex, editing, table, structures) 17.5 s, 1.43 GB 14.1 s, 1.04 GB —

(Upsilon on Guile currently fails to load the test suites, so the last row is missing.)

So it confirms what Joy saw:

  • Where the work is really done in Scheme (conversions), Chez is 3–4× faster than s7.
  • Interactive editing is dominated by the C++ side and the run-time eval from C++, so there it changes much less.
  • Memory grows more slowly than with s7 under load, but at startup it is higher, because of the boot image.

Joy, two things I’d like to look at next, if you’re interested:

  1. The size of the boot image. It is 19.6 MB, mostly because of vfasl, which saves only about 60 ms at startup and costs about 50 MB of RAM, and the inspector information, about 40% of the compiled code. Plain fasl without inspector information would be about 7.7 MB.
  2. Shipping only the boot image and compiling the remaining modules lazily, in the background, at the first start.

Builds for Linux and Windows would also be welcome, if you still have your setup for Ubuntu and MSYS2.

Thanks again for the work. Without your compiler this would have taken much longer.

1 Like

Hi Max,

Thanks for the merge works! Surprised that you did it this fast and passed all the tests :slight_smile:.

I will take a look today and maybe give some comments at Github issues instead of here.

For the two questions you note:

  1. As for the boot image, I didn’t know that vfasl would cost so much more memory at steady state. From information gathered by my LLM, it would just load faster (since it doesn’t have to do any GC; fasl will have to run GC like normal scheme engine would during startup). I guess I need to run some actual tests to confirm this. Ultimately, if it’s just the boot image size tradeoff, I guess there are other means to bring down the size of the app – note that fasl size is much smaller because the boot file is compressed.
  2. Shipping only boot image: I’m not sure how to understand this: do you mean to keep only the scheme code of (non-essential) modules (.scm) and have the compiler script run on it and produced a binary (.so), and then load it? I guess it would only slow down the boot process – with maybe the advantage that you can add/edit modules even in the installation site? I guess it makes sense for the plugin system, but not for the main modules we ship – because we can already compile them and save works for users. This means that the scheme codebase works like the C++ counterparts. Note that the compiler script probably can’t handle a lot of the code being thrown at.

I can try to compile on Linux/Windows and give a build guide – do you want the final built packages also?