Skip to content

Draft: faster z-encoder and remove cached z-encoded strings from FastString table

Luite Stegeman requested to merge luite/ghc:zenc into master

This is a WIP to see if the cached z-encoded strings in the FastString table can be removed if we just make the z-encoder faster.

There's still quite a bit of cleanup to do, and part of the API changes I made in the first revision can probably be reverted. The first revision is in my quick testing over 10x faster than the existing z-encoder (that requires converting to a String first), the inner loop doesn't allocate.

There is no C code, but the Haskell is low level and operates on Ptr CChar. The API is pure, but there's inlinePerformIO in a few places. I started out hoping to avoid inlinePerformIO (and only actually encoding in hPutFZS), but I'm not sure if that's doable without much performance loss.

No tests yet. Depending on whether there's still a use case for the old encoder we could keep it in GHC.Utils.Encoding. Or we can move the old "reference encoder" to a testcase to compare.

Merge request reports