[ic] IC loop performance secret

Grant emailgrant at gmail.com
Tue Nov 15 00:21:48 UTC 2011

Not actually a secret, but I've found a way to greatly increase the
performance of loops with many iterations thanks to a tip from Peter
over 2 years ago:


I didn't realize that loops build a string of ITL that is executed
once the loop has completely finished processing.  This is explained
by the IC parsing order but it didn't click for me until I recently
read back over Peter's explanation.  Loops with many iterations can
build extremely long strings, and on my system the longer the string
the slower the execution.  Way slower.  I've been able to completely
eliminate this performance slowdown by putting the code executed by
the loop in includes.  Something like this builds a 500,000-line

[loop search="ml=1000/ra=1"]
500 lines of non-looping ITL here

and something like this builds a 1,000-line string:

[loop search="ml=1000/ra=1"]
[include includes/some_code]

If the 500 lines of non-looping ITL are stored in the file
"includes/some_code", the code executed after looping is the same in
either example, but the second example executes many times faster on
my system.  Is this performance disparity expected or is there likely
a problem somewhere in my system?  I have plenty of free memory during
the slow execution of the code in the first example.

- Grant

More information about the interchange-users mailing list