Repository navigation
libghostty backend #1947
Replies: 4 comments 1 reply
|
A few more things I found while poking at this:
|
|
Hey @maciej-lech I am with you on the performance gap between the vt tuios ships (which is a fork of charms implementation: https://github.com/charmbracelet/x/tree/main/vt) and libghostty and it has bugged me too ever since I have supported libghostty but not had it as the default. I have been wanting to make libghostty the default backend for tuios for a while now but there have been two main blockers... one which you correctly pointed out that it is not "portable" as in it adds a dependence on cgo since it has to include libghostty as a C static lib and the second which was my bigger concern of libghostty being pre 1.0 i.e. there were no API stability guarantees which was the case until less than a week ago when Mitchell blessed us with v1.0 (https://mitchellh.com/writing/libghostty-1-0). I would still like to keep maintaining the pure go backend for portability reasons and to make tuios cross compile to crazy targets (it currently even works natively on android and over wasm in a browser for example), but yes now that libghostty is finally 1.0 I will most definitely be switching over libghostty to be the default backend for tuios and the pure go version will become a separately available binary moving forward. Edit: After writing this it also reminded me of another reason I hadn't made the libghostty backend the default, its again CGO, but this time its the cost it carries in terms of latency... CGO has an implicit cost associated with every call that crosses the go <-> c boundary, this would mean every character you type crosses this boundary and pays that cost, although in the grand scheme of things if libghostty is that much faster, this cost gets offset and becomes negligible/unnoticeable... so yes in either case switching to libghostty absolutely does make sense and now post v1.0 even more so! Expect libghostty as the default backend soon 🤞 either in v0.12.2 (which I plan to land either tonight or tomorrow or at the very latest in v0.13.0 which should also be pretty soon in a week or two at the max) |
|
Thanks for the detailed answer, I'm super happy that this is the plan! Keeping the pure Go backend as a separate binary makes total sense. It could be even the default for And no rush on my side - it doesn't have to land in a patch release. Switching the default emulator is a pretty visible change, so v0.13.0 feels like a natural place for it, with time for libghostty 1.0 to settle in. Meanwhile I'm happily running the ghostty build. If it helps, I'm happy to help with the packaging side (Homebrew formula, shell completions in the archives) once the direction is settled |
|
Quick follow-up, because I went and measured this properly instead of trusting my memory (or my own docs). Both backends, same commit of main, each in a real daemon with a real client attached, runs interleaved on a quiet machine, 8 runs each. Time is from sending the command to the output being done on screen (medians):
CPU over the same span:
So you were right @maciej-lech: big output is faster with libghostty, and with a few busy panes it's a lot less CPU. The frame rate while it scrolls is the same on both (about 70 to 80 fps), it just gets there sooner. Two corrections on my side:
It's not all one way though, and I'd rather say it now than after a switch. The way tuios talks to libghostty today is slow for a few things that have nothing to do with the library's parser: search and selection over a long scrollback, resizing with a lot of history, and very small writes (my adapter makes 13 or so cgo calls per write). That's my code, so it's fixable. The ghostty build also fails more of my conformance cases than the Go emulator right now (I still need to go through which side is right on each), and it's a couple of MB over the size budget I hold the binary to. I'm measuring memory and fuzzing the binding next. For anyone who wants to check me: tuios main at I'll post the rest (memory, the slow spots after I fix the adapter, the conformance diff) when I have it. |
Uh oh!
There was an error while loading. Please reload this page.
Hey!
I am wondering why two backends? For me, libghostty backend is much faster and I am wondering why support two? And why libghostty is not the default? I know that cross-compilation requires zig toolchain, but is it a big deal?
When I first tried tuios, despite great first impression in terms of UI and features, it wasn't as fast for printing larg amount of text as herdr that I came from. Only when I switched to libghostty backend, which I almost missed its existence, the experience was equally good - which is understandable as herdr uses libghostty as well.
I guess that to compete with herdr and soon rex UX, the fastest backend should be at least the default one :D
Best regards,
Maciej
All reactions