Re: Edita on 4.0b3 (r3124)

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

Thanks, that's very helpful. Basically, the temp referenced in the length call doesn't get released until after the end if. I suppose the better way to deal with this is to insert a DEREF_TEMP at the start of the main if block, each elsif block, and the final else block. The key, though is noticing when there is no else block, and creating one to make sure the temp is not leaked.

This is now fixed in svn:3131.

Matt

Thanks. I am pleased to say Edita now runs OK on r3132

Of course I immediately tried something else ("if filetext[1]=filetext[1] then", if you must know) which ran fine on r3132 but gave me problems on Phix. So, I examined your mods to parser.e, which gave me two thoughts:

(NB: this is now firmly in low-priority territory)

First, you may not need the additional code. My analysis (I use different opcodes to you, remember) was that only 8 things create dangerous refcounts (move?, subscript, slice, append, prepend, concat, repeat, and make sequence), and only 8 things "clone" due to non-1 refcounts (replace element, replace slice, append, prepend, concat, make sequence, repeat, and of course any form of call). Hence eg:

    if length(filetext[1]) then 
        flag = 1 
    end if 

Whether you can avoid the extra code in such cases is another matter.

Secondly, the beast that is the hidden temp of function return values:

object x, y 
constant MAX = 10000 
atom t0, t1, t2 
function f(object x) return x end function 
t0 = time() 
for i=1 to MAX do 
    x = repeat(1,100000) 
    if length(f(x)) then 
        x = append(x,1) 
    end if 
end for 
t1 = time() 
y = repeat(1,100000) 
for i=1 to MAX do 
    x = repeat(1,100000) 
    if length(f(y)) then 
        x = append(x,1) 
    end if 
end for 
t2 = time() 
printf(1,"with:%3.2fs, without:%3.2f\n",{t1-t0,t2-t1}) 
--if getc(0) then end if 


Much less severe than previous examples, about 6x slower (not at all bad compared to the expected 100,000 times slower!), and as said no impact on any real-world code, just thought you might like to know.

Regards, Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu