Open hasufell opened 4 years ago
Hmm, unfortunately I don't know too much about haskell performance, so I can't really say off the top of my head what's causing all the allocations. The parser certainly wasn't written with performance in mind.
If you know the files you're parsing are going to be in this nice list-of-variables format, maybe it would be better to use a custom parser?
I also notice you're parsing each file twice: https://github.com/haskell/ghcup-hs/blob/fafff9dadd60e7f85d1fdea00b324bae7b40164c/lib/GHCup/Platform.hs#L153
If you know the files you're parsing are going to be in this nice list-of-variables format, maybe it would be better to use a custom parser?
I started that already, but I don't think it's a good idea. There are so many assumptions when doing a naive parser and I won't have an easy way of knowing whether a valid user file was incorrectly parsed, because these are silent failures.
On the other hand it seems this is only a shell subset: https://www.freedesktop.org/software/systemd/man/os-release.html
So maybe feasible after all.
I also notice you're parsing each file twice: https://github.com/haskell/ghcup-hs/blob/fafff9dadd60e7f85d1fdea00b324bae7b40164c/lib/GHCup/Platform.hs#L153
good catch
I use language-bash in ghcup to parse variable assignments from files like
/etc/os-release
: https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/lib/GHCup/Utils/Bash.hsThis works relatively well, but when I profile ghcup on the simplest command
ghcup list
, I get this:This is on a 7 LOC bash file:
I'm wondering if there's a way to reduce the allocations.