Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: reduce glyph memory consumption by 57%
I learned about optimal memory layouts recently [1] and remembered that glyphs waste a lot of space, especially the flags. This new struct was a pain to get working: I tried DataView first, but it performed worse in node. I didn't want the class to take up a lot of memory, so I finally landed on TypedArray with bit shifting and maksing. Performance is pretty much the same as before, although sadly perf-1 runs a tiny bit slower. The memory savings are good, though, and readability is significantly better. I may explore AST transforms to inline the function calls later. perf-2 is a little bit faster, which is probably due to better CPU cacheability. [1] https://www.youtube.com/watch?v=rX0ItVEVjHc
- Loading branch information