#2284: Stack-hack optimization causes much re-computation in GUI callbacks
--------------------------+-------------------------------------------------
Reporter: sedillard | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Multiple
--------------------------+-------------------------------------------------
This is a duplicate of #1168, recorded for posterity here, at the request
of Simon PJ,
http://www.haskell.org/pipermail/glasgow-haskell-
users/2008-May/014739.html
An IO lambda is created within main's scope, and this is given to the GLUT
GUI library (or it could be GTK or wxHaskell) as a callback to draw the
contents of the window. The callback lambda captures a value from the
outer scope, but the state-hack inlines the value's defining expression
into the callback. Thus, the value is re-computed every time the callback
is called.
-fno-state-hack fixes it.
The attached program is a 3D model viewer. I've attached two models, one
is small, the other larger. The performance hit is quite noticeable on the
large one. The models need to be unzipped before running.
{{{
gunzip torus.obj.gz
./ObjView torus.obj
}}}
use x y z to rotate and force a redraw. When compiled with -O0 or -fno-
state-hack, you'll see "BUILDING MESH" output once, otherwise it will be
output on every redraw.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2284>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs