Tcl Source Code

View Ticket
Login
Ticket UUID: 1693802
Title: INST_INVOKE speedup
Type: Patch Version: None
Submitter: msofer Created on: 2007-04-03 17:51:10
Subsystem: 47. Bytecode Compiler Assigned To: msofer
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-04-04 20:21:29
Resolution: Accepted Closed By: msofer
    Closed on: 2007-04-03 22:55:57
Description:
Attached a patch that avoids calling out to TEOVi when possible.
User Comments: msofer added on 2007-04-04 20:21:29:
Logged In: YES 
user_id=148712
Originator: YES

Those comments will be added, thank you.

I did not run the full benchmark suite, but did see 10-20% speed improvements in the OO microbenchmarks for different OO systems.

As to the mistery about "calling out of TEBC is expensive", my comments are:

(1) that is surely a bad explanation: the new code does one function call out of TEBC (possibly more), just like the old one

(2) here we are inlining a very specialised version of TEOvI: flags==0, no traces, the Command is already known to exist and known. IOW, we are replacing a 100+ loc function (assuming ~50% comments) with 10 loc in TEBC. In Chuck Moore's manner of speaking: we are deciding many things at edit time (like flags=0) instead of checking at run time.

(3) Very aggressive refactoring could be a different way of attaining similar results, but I am not sure that TEOvI_reallyInternalCircle0Ex() would be an addition that would make maintenance much easier ;)

My guess is that (2) has positive effects on cache behaviour, possibly depending on how clever the compiler/cpu combination is about prefetching. The effect might also be obtained with good compiler hints, but those tend to be non-portable (eg, gcc's __builtin_expect for branches) and also harder to maintain.

dgp added on 2007-04-04 11:06:35:
Logged In: YES 
user_id=80530
Originator: NO


I dislike this.  Adding another
command dispatch location just
invites divergence, leading to
more problems like 582506.

I assume the speedup must be
compelling for you to go ahead
with this anyway.  Which suggests
it's our old mystery of "why do
function calls out of TEBC cost
so much?"  When the genie next grants
us wishes, I'd rather we figure that
out and solve that, than do things like this.

If you stick with this commit, at
least add some comments in
the TEOVI routine that any changes
made there need to be examined for
possible copying over to the
INST_INVOKE area.

msofer added on 2007-04-04 00:51:12:

File Added - 223596: instInvoke.patch

Attachments: