
#9885: ghc-pkg parser eats too much memory
-------------------------------------+-------------------------------------
Reporter: gnezdo | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: ghc-pkg | Version: 7.8.3
Keywords: | Operating System: Linux
Architecture: Unknown/Multiple | Type of failure: Runtime
Difficulty: Moderate (less | performance bug
than a day) | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Parsing of spec files in ghc-pkg scales very poorly. The following script
demonstrates memory consumption growth as a function of the number of
tokens in ld-options (16K leads to ~6G)
#!/bin/bash
# Demonstrates memory consumption behavior of ghc-pkg as a function of
# the number of ld-options arguments.
for i in {10..14}; do
size=$((1 << $i))
echo $size
rm -fr a.packages
/usr/bin/ghc-pkg init a.packages
cat > a.spec <