|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] Internal storage of iota |
Date: | Mon, 28 Apr 2014 14:20:43 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
Hi Blake,
it is definitely saving space, but it most likely taking more time. Consider Z←A ⍴ IDX← ⍳ N to represent the creation (IDX ← ⍳ N) and use (Z ← A ⍴ IDX) of IDX. At ravel cell level a cell is created with constructor IntCell() and used with get_ravel(r). The argument of IntCell is a simple integer that is incremented and that part can be neglected. So the current implementation takes time A timeof(get_ravel) + N timeof(IntCell). A lazy computation of ⍳ would take time A timeof(IntCell) instead. Now timeof(get_ravel) is slightly smaller than timeof(IntCell) so you can gain only if A < N1 where N1 is somewhere between N and 2N. For larger A lazy computation cost more. An even worse thing is the collateral damage of such an optimization. We would get two types of Values: the "normal ones" and those computed when referenced. The consequence would be that get_ravel() becomes virtual which adds cost for all accesses to ravel cells. Currently get_ravel() is inlined and should be one or two assembler instructions for a good compiler. A virtual get_ravel() would be a function call via the vtable of IDX instead because the compiler cannot decide which type of value is being used. That all suggests IMHO to not do it. The general problem with this and similar optimizations is that the optimization considered alone can be drastic, but the overall gain of it can still be negative. /// Jürgen On 04/27/2014 06:27 PM, Blake McBride wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |