Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's probably lots of room for optimization, for example currently it sets and resets all sorts of GPU state on each print call, for each character, which is rather expensive:

https://github.com/liamg/aminal/blob/master/glfont/font.go#L...

Speaking of the main loop, for every columm and every row:

    cx := uint(gui.terminal.GetLogicalCursorX())
which in turn calls another function -- move that outside of the loop and do it once. Generally buffer values that don't change and get used in loops, instead of fetching them by calling functions on each iteration.

Also, while it may not matter much in this case unless there are other sources of GC churn, just because I noticed it: don't create an array for the vertices for every character to then throw it away and recreate it, have one and keep reusing that.



If you have good generational GC (with relocation), then creating and destroying short-lived objects should be almost free?

In practice, you will be re-using the same areas of memory.


Go's GC is deliberately non-relocating, which precludes being generational. https://blog.golang.org/ismmkeynote The repeated state in question might be benefiting from escape analysis, but I can't tell from a cursory examination.


Sure, but almost free GC is free in the same way throwing away 3 cents is almost free. Once it adds up enough to cause lost frames, anyway. Just like a straw practically weighs nothing, except when it's the straw that causes the camel to miss a frame.

In this case, I also doubt it would make a difference by itself, but I haven't looked at all of the source, so I just mentioned it as something to maybe watch out for. Also, every bit of GC you can super easily avoid "buys" you room for GC that would make the code more complicated to avoid. Waste not, want not :)


Ok, drop the 'almost'. GC can be as 'free' as eg stack allocation (which nobody seems to mind to much).

See the comment by kibwen (https://news.ycombinator.com/item?id=18551218) for some good pointers to more concepts.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: