[GHC] #14161: Performance Problems on AST Dump

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.3 Keywords: | Operating System: Linux Architecture: x86_64 | Type of failure: Compile-time (amd64) | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Using the latest self compiler ghc ghc -O -ddump-to-file -ddump-parsed-ast with the file https://raw.githubusercontent.com/h4ck3rm1k3/gcc- ontology/master/tests/example_python_ast_in_haskell.hs After 2 hours I stopped it : PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20 0 1.000t 0.014t 0 D 3.3 94.0 108:29.80 ghc -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump
-------------------------------------+-------------------------------------
Reporter: h4ck3rm1k3 | Owner: (none)
Type: bug | Status: new
Priority: low | Milestone:
Component: Compiler | Version: 8.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Compile-time | (amd64)
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by h4ck3rm1k3):
/usr/local/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.3.20170819
git log :
commit 1cdceb9fa3bc3ad01b2d840caad8e735513e14ed
Author: Ben Gamari

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: new Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * owner: (none) => dfeuer * milestone: => 8.2.2 Comment: I think I have a decent guess about what might be going on here. It looks like there's lots and lots of recursive string concatenation going on. Let me see if I can fix it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: new Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Actually, that's only one piece of the puzzle. Another major problem is that when `showAstData` is called in `HscMain`, its (`String`) result is converted to an `SDoc` using `text`. In order to even think about rendering that result, `Pretty` calculates its length. This forces the entire dump to be built in memory as a `String`. I don't have enough memory to do that on my system! I'm working on a patch to make `showAstData` produce a `Doc` right from the start rather than a `String`. Initial experiments suggest that this has a much better chance of working. One question: when should one produce a `Doc` and when should one produce an `SDoc`? I'm pretty unclear on that bit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: new Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Yep, my patch fixes this problem. I just need to figure out the `Doc`/`SDoc` business and I can upload a differential. My patched version produces somewhat different formatting (I'm no pretty printing expert), but it doesn't look horrible or anything. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: new Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * differential: => Phab:D3894 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: new Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Comment (by h4ck3rm1k3): Noob question, I cannot see this branch on the git://git.haskell.org/ghc.git and for some reason I cannot fetch from the phab : git fetch https://phabricator.haskell.org/diffusion/GHC/glasgow-haskell- compiler.git fatal: unable to access 'https://phabricator.haskell.org/diffusion/GHC /glasgow-haskell-compiler.git/': The requested URL returned error: 500 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: patch Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Compile-time | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: patch Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * architecture: x86_64 (amd64) => Unknown/Multiple -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Noob question, I cannot see this branch on the git://git.haskell.org/ghc.git and for some reason I cannot fetch from the
#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: patch Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Replying to [comment:6 h4ck3rm1k3]: phab :
git fetch https://phabricator.haskell.org/diffusion/GHC/glasgow-haskell-
compiler.git
fatal: unable to access 'https://phabricator.haskell.org/diffusion/GHC /glasgow-haskell-compiler.git/': The requested URL returned error: 500
The branch isn't on git.haskell.org because I haven't put it there. I suppose I could if you like. As for getting branches from Phabricator.... um ... I'm not the best at that. I think you can use `arc patch` or something, maybe? bgamari could say for sure. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: patch Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Sadly Phabricator Differentials aren't automatically branches. dfeuer will need to push the branch to git.haskell.org in order for you to check it out with git. Alternatively you can use arcanist to apply the differential (e.g. `arc patch D3894`) or you can download the patch from Phabricator and apply it to your tree manually. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump
-------------------------------------+-------------------------------------
Reporter: h4ck3rm1k3 | Owner: dfeuer
Type: bug | Status: patch
Priority: low | Milestone: 8.2.2
Component: Compiler | Version: 8.3
Resolution: | Keywords:
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3894
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by David Feuer

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: merge Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: patch => merge Comment: I suspect this is small enough to merge. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: merge Priority: low | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Out of curiosity, what are you using the output of this command for, h4ck3rm1k3? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14161: Performance Problems on AST Dump -------------------------------------+------------------------------------- Reporter: h4ck3rm1k3 | Owner: dfeuer Type: bug | Status: closed Priority: low | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3894 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: 8.2.2 => 8.4.1 Comment: I have spoken with h4ck3rm1k3 and he says that he doesn't need this for 8.2.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14161#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC