I've been following the development of Ghostty for a while and while I have the feeling that there is a bit of over-engineering in this project, I find this kind of bug post mortem to be extremely valuable for anyone in love with the craft.
Over-engineered in what way?
Finding and fixing Ghostty's largest memory leak
91–100 of 152 posts
Re: Finding and fixing Ghostty's largest memory leak
#92Earlier quoted context omitted.
Was going to say this, but I don't think anyone actually wants to hear that Rust actually would have helped here. As you're saying, the bug was the equivalent of an incorrectly written Drop implementation. Nothing against Zig, and people not using Rust is just fine, but this is what happens when you want C-like feel for your language. You miss out on useful abstractions along with the superfluous ones. "We don't need…
If you wanted to match Ghostty's performance in Rust, you'd need to use unsafe in order to use these memory mapping APIs, then you'd be in the exact same boat. Actually you'd be in a worse boat because Zig is safer than unsafe Rust.
Calling unsafe mmap APIs not only is unlikely to run into the corner cases where unsafe Rust is tricky to get right, there’s “millions” of crates that offer safe APIs to do so and it’s fundamentally not hard to write it safely (it would be very hard to write it to have any issues).
And fundamentally I think Rust is much more likely to be easier to get high performance because the vast majority of safe code you write is amenable to the compiler performing safe optimizations that Zig just can’t do regarding pointer aliasing (or if it does brings all the risks of of unsafe Rust when the user annotates something incorrectly).
Re: Finding and fixing Ghostty's largest memory leak
#93I hate to say it, but this probably would not have happened in a garbage collected language. GC languages are fast these days. If you don't want a runtime like C# (which has excellent performance) a language like Go would have worked just fine here, compiling to a small native binary but with a GC. I don't really understand the aversion to GC's. In memory constrained scenarios or where performance is an absolute top…
I agree that garbage collection is fine and Go indeed has an amazing garbage collector. Unfortunately, it also has the worst type system of all mainstream languages created in the 21st century, so the benefits are rarely worth the drawbacks.
Re: Finding and fixing Ghostty's largest memory leak
#94Earlier quoted context omitted.
I honestly don't understand why a terminal emulator needs to be performant. Seems like peak bikeshedding to me.
A lot of developers use the terminal as their primary interaction with the computer. Nvim, tmux, etc. Having it be fast is an extreme quality of life improvement. For devs who only ever use the terminal integrated into their ide then it’s probably less important.
I have never found myself in the situation where my terminal emulator would be too slow and I‘m using it for the majority of my day-to-day work.
I honestly never ran into a situation where I would habe blamed the terminal emulator for being too slow.
Re: Finding and fixing Ghostty's largest memory leak
#95Earlier quoted context omitted.
I am not sure on what your commented is based on, but in short: No? High performance software needs to deal with memory, and optimisations often will need some kind of direct control - as in this example where re-using memory is more performant than constantly churning with mmap.
I honestly don't understand why a terminal emulator needs to be performant. Seems like peak bikeshedding to me.
Re: Finding and fixing Ghostty's largest memory leak
#96Earlier quoted context omitted.
If you wanted to match Ghostty's performance in Rust, you'd need to use unsafe in order to use these memory mapping APIs, then you'd be in the exact same boat. Actually you'd be in a worse boat because Zig is safer than unsafe Rust.
Please don’t get defensive and spread silly FUD. You can be proud of what you’ve accomplished without feeling sad that a different language has strengths that yours doesn’t. Calling unsafe mmap APIs not only is unlikely to run into the corner cases where unsafe Rust is tricky to get right, there’s “millions” of crates that offer safe APIs to do so and it’s fundamentally not hard to write it safely (it would be very h…
Re: Finding and fixing Ghostty's largest memory leak
#97Earlier quoted context omitted.
Over-engineered in what way?
Having to introduce a new language stack to distributioms just to be able to build a terminal emulator is what I would consider over-engineering.
Re: Finding and fixing Ghostty's largest memory leak
#98I hate to say it, but this probably would not have happened in a garbage collected language. GC languages are fast these days. If you don't want a runtime like C# (which has excellent performance) a language like Go would have worked just fine here, compiling to a small native binary but with a GC. I don't really understand the aversion to GC's. In memory constrained scenarios or where performance is an absolute top…
Re: Finding and fixing Ghostty's largest memory leak
#99I hate to say it, but this probably would not have happened in a garbage collected language. GC languages are fast these days. If you don't want a runtime like C# (which has excellent performance) a language like Go would have worked just fine here, compiling to a small native binary but with a GC. I don't really understand the aversion to GC's. In memory constrained scenarios or where performance is an absolute top…
Why do you think trippling the memory usage of a program is an acceptable tradeoff? It's not just GC pauses that are problematic with gc languages. Some software wants to run on systems with less than 4GiB of RAM.
Re: Finding and fixing Ghostty's largest memory leak
#100Earlier quoted context omitted.
I am not sure on what your commented is based on, but in short: No? High performance software needs to deal with memory, and optimisations often will need some kind of direct control - as in this example where re-using memory is more performant than constantly churning with mmap.
I honestly don't understand why a terminal emulator needs to be performant. Seems like peak bikeshedding to me.