Ticket UUID: | 453709 | |||
Title: | optimize ExceptionRange lookups | |||
Type: | Patch | Version: | None | |
Submitter: | msofer | Created on: | 2001-08-21 12:54:27 | |
Subsystem: | 47. Bytecode Compiler | Assigned To: | msofer | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2002-06-20 20:21:49 | |
Resolution: | Postponed | Closed By: | msofer | |
Closed on: | 2002-06-20 13:21:49 | |||
Description: |
This patch modifies the use of ExceptionRange by the compiler/engine in two ways: - moves the computation of the ending offset of the range to compile time (instead of runtime) - exploits the order in which nested exception ranges are stored to reduce the number of runtime comparisons - it traverses the list of exception ranges in reverse order, thus insuring that the deepest range is found first. | |||
User Comments: |
msofer added on 2002-06-20 20:21:49:
Logged In: YES user_id=148712 Most of these ideas are now in the HEAD hobbs added on 2002-06-20 05:42:40: Logged In: YES user_id=72656 pushing this back to miguel due to the number of changes he has made to TEBC recently. msofer added on 2002-03-07 19:46:32: File Added - 18961: newRangeNPeep.patch msofer added on 2002-03-07 19:46:31: Logged In: YES user_id=148712 I keep packing stuff in this patch ... The new newRangeNPeep.patch adds - peep-hole optimisation in INST_FOREACH4: avoids (creating, pushing, popping, testing, destroying) an object and saves executing an INST_JUMP_FALSE. - peep-hole optimisation in several instructions: avoids pushing an object that will be popped right away and saves executing an INST_POP. The first column is the patched version: 000 VERSIONS: 1:8.4a5 2:8.4a5 001 LOOP for (to 1000) 1328 1433 002 LOOP for, iterate list 1977 1993 003 LOOP for, iterate string 2631 2618 004 LOOP foreach, iterate list 872 1149 005 LOOP foreach, iterate string 1104 1385 006 LOOP while (to 1000) 1294 1427 007 LOOP while 1 (to 1000) 1005 1088 007 BENCHMARKS 1:8.4a5 2:8.4a5 Remark that this (and many other optimisations) would be simpler and more efficient if we settled on not being able to run older style bytecode, and providing a "translator" in tbcload. BTW, are the .tbc files versioned, or does proComp only use the 8.0 compiler avoiding the newer instructions? msofer added on 2002-03-07 06:06:40: File Added - 18927: newRange2.diff Logged In: YES user_id=148712 Improved patch, modifying also some ExceptionRange related tools in tclCompile.c. As a side effect, I applied the "loop rotation optimisation" to [foreach], eliminating one jump from the loop. msofer added on 2002-03-06 21:44:36: File Added - 18891: newRange.diff Logged In: YES user_id=148712 New patch: this one does only modifies the runtime lookup algorithm, but does not touch the compiler. Checking with Jeff if .tbc code will not be broken, i.e., if it satisfies the assumption: "nested ranges are always *after* their containing ranges" The gains are illustrated with tcllib patch #526404 (tclbench): TCL_INTERP: 1:8.4a4 2:8.4a4 STARTED 2002-03-06 11:38:10 (runbench.tcl v1.13) Benchmark 1:8.4a4 /CVS/tcl_SF_clean/unix/tclsh0 c 00:00:00 elapsed 126 milliseconds Benchmark 2:8.4a4 /CVS/tcl_SF_clean/unix/tclsh-newRange c 00:00:00 elapsed 105 milliseconds 000 VERSIONS: 1:8.4a4 2:8.4a4 001 CATCH error, complex 58 47 002 CATCH no catch used 3 3 003 CATCH return error 28 28 004 CATCH return ok 4 3 004 BENCHMARKS 1:8.4a4 2:8.4a4 FINISHED 2002-03-06 11:38:10 msofer added on 2001-08-22 01:13:25: Logged In: YES user_id=148712 The speed effect is just about nil (but positive); even so, I still like it: it looks cleaner to my eyes. OTOH, it may break tclPro's compiled bytecodes. Better leave that alone for now. msofer added on 2001-08-21 22:30:28: Logged In: YES user_id=148712 The speed effect of the patch seems to be negative ... msofer added on 2001-08-21 19:54:28: File Added - 9785: except.diff |
Attachments:
- newRangeNPeep.patch [download] added by msofer on 2002-03-07 19:46:32. [details]
- newRange2.diff [download] added by msofer on 2002-03-07 06:06:40. [details]
- newRange.diff [download] added by msofer on 2002-03-06 21:44:36. [details]
- except.diff [download] added by msofer on 2001-08-21 19:54:28. [details]