WIP: Reduce allocations from FastString and allow string pool to be gced
This patch contributes two changes.
- Reduce the total allocation from
FastString
by removing unnecessary fields. The only necessary field in theFastString
was theByteString
. The change removes about 7 words per allocation, when GHC allocates over 80 000FastString
s during a compilation, the reduction in memory usage is significant. Equality is computed by reference equality of the underlying ByteString. - Allow the string pool to be GCd by using weak pointers. This change necessitated removing the
Unique
instance forFastString
, which was bogus anyway, and introducing some specificFastString
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