On Mon, 2006-07-10 at 00:59 -0700, Erick Tryzelaar wrote:
[]
Erick, I just looked at your 'slow' program: it turns
out all the time is being taken in the inliner NOT in
the lookup module.
The problem is basically this: when a function is inlined,
all its children have to be copied and reparented so the
new copies belong to the function into which the body is inlined.
Match expressions create LOTS of kids! It's basically
fun match() {
var mv = expr;
fun match_checker1() { .. check if it matches .. }
fun match_handler1() { .. handle the match case ..}
...
}
So if you have nested matches you get a whole tree of stuff.
Unfortunately, when the outer level is inlined the whole
tree is cloned/reparented .. and now we have TWO trees.
In 'the old days' an attempt was made to keep track
of usage, and in cases like matches where functions are
only every called once, the original functions were
deleted.
Unfortunately this never worked properly and I had to
comment that code out. So now after one inlining we
have two trees and they BOTH get optimised.
Each child being optimised again clones its child
tree .. so the process is exponential.
Now actually inlining is done from the leaves into their parents.
But after the inlining .. the leaves are still there .. even though
they're not called .. because the code eliminating them is disabled.
The bottom up stuff relies on the fact the function dictionary
is mutable -- a functional version of the algorithm would never work.
Once inlining is done into a function, it is physically replaced
and marked as being optimised, so inlining is never done into
a function more than once.
The problem is that a clone of a function isn't the same function.. :)
Frankly .. I don't even have a proof the process converges,
since it created NEW functions and doesn't eliminate any
since i disabled the pruning code.
The offending line is:
and remove_unused_children syms (uses,child_map,bbdfns) i = () (*
which as you can see comments out the pruning routine ;(
OK .. for the record:
[EMAIL PROTECTED]:/work/felix/flx$ time flx --test --force erick
erick.cpp: In member function ‘virtual flx::rtl::con_t*
flxusr::erick::_i54199_p2798_inner::resume()’:
erick.cpp:557: error: cannot convert ‘flxusr::erick::_a1190t_54129’ to
‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’
compilation terminated due to -Wfatal-errors.
real 1m21.428s
user 1m20.597s
sys 0m0.412s
[EMAIL PROTECTED]:/work/felix/flx$ time flx --test --force --noinline
erick
erick.cpp: In member function ‘flxusr::erick::_us2
flxusr::erick::regmatch675::apply(const flxusr::erick::_at4287&)’:
erick.cpp:1244: error: no matching function for call to
‘flxusr::erick::regmatch675::apply(flxusr::erick::_a1190t_3990,
flxusr::erick::_a1190t_3990&)’
compilation terminated due to -Wfatal-errors.
real 0m0.823s
user 0m0.748s
sys 0m0.068s
so .. 1 minute 28 seconds with inlining on, and 0.8 seconds with
inlining off.
With the routine enabled and inlining ON:
[EMAIL PROTECTED]:/work/felix/flx$ time flx --test --force erick
erick.cpp: In member function ‘flxusr::erick::_us2
flxusr::erick::regmatch675::apply(const flxusr::erick::_at4955&)’:
erick.cpp:496: error: no matching function for call to
‘flxusr::erick::regmatch675::apply(flxusr::erick::_a1190t_4879,
flxusr::erick::_a1190t_4879&)’
compilation terminated due to -Wfatal-errors.
real 0m0.810s
user 0m0.724s
sys 0m0.076s
So clearly that routine needs to be made to work .. unfortunately
I could never track down why it doesn't.
However .. none of the regression tests fail! So the routine
is re-enabled. Remind me when we get a test case that fails
(a) fix the dang build system so we can tolerate faulty tests
otherwise I won't add them to the test suite for fear it will
break the build.. self-defeating
(b) an option to turn off the pruning to work around the bug,
if it still exists
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language