|
From: Bryce K. <br...@ka...> - 2004-04-08 19:38:49
|
Ned Konz writes: > On a related note, does it seem wasteful to anyone but me that we do the > following in primBytecodeAdd: Yes, that sequence does seem wasteful. Ideally I'd like to generate: and arg1, arg2, andResult and andResult, 2r11, dummy1 branch-if-not-zero overflowBlock add addResult, arg1, arg2 branch-on-overflow overflowBlock This sequence is possible if we change from integers having tag 1 to integers having tag 0 leaving the tag in the lower bits. The Self community wrote some nice papers on tagging and high performance simple garbage collection. The above sequence only has the add on the critical path during the common case where the arguments are SmallIntegers and the result is also a SmallInteger. The other four instructions do not matter so long as both branches are correctly predicted as not taken. Looking up oops can be done by using the small offset provided in most load or store instructions. This means that a non-zero oop tag has no overhead. But interpreted code probably spends most of it's time recovering from branch mispredicts. Compiled code should be sufficiently faster that the garbage collector will be the major bottle-neck. Realistically any changes to tagging should be looking to provide a large improvement to garbage collector performance. It would probably be more worthwhile looking at at: and at:put:. Could Tim's improvements to primitives be used to create simple at: primitives that are quick to execute? My limited benchmarking indicates that code using arrays is dominated by at: and at:put: overhead. We're not yet at the point where our inefficient SmallInteger format matters. Once we're at the point where SmallInteger addition is worth improving our garbage collector will be a serious bottleneck. Currently the garbage collector uses about 10% of the time reduce the 90% by enough to make these few instructions matter and garbage collection will be closer to 50%. So, yes it does seem wasteful, but first let's improve things so that the waste really matters. Even then other things (the garbage collector) will be more important which require image changes. Anything that simplifies and speeds up at: and at:put: will matter much more. Tim, that primitive work? Bryce |