Skip to content

WIP: Reduce allocations from FastString and allow string pool to be gced

Matthew Pickering requested to merge wip/faststring-weak into master

This patch contributes two changes.

  1. Reduce the total allocation from FastString by removing unnecessary fields. The only necessary field in the FastString was the ByteString. The change removes about 7 words per allocation, when GHC allocates over 80 000 FastStrings during a compilation, the reduction in memory usage is significant. Equality is computed by reference equality of the underlying ByteString.
  2. Allow the string pool to be GCd by using weak pointers. This change necessitated removing the Unique instance for FastString, which was bogus anyway, and introducing some specific FastString maps which make sure the keys to the maps don't get garbage collected too early. Before this change, if you used the GHC API then the string pool would constantly grow and leak memory.

The patch should compile now, put up here for CI purposes.

See #17059

Merge request reports