Re: [TCLCORE] [SPAM] [6.0] Re: base64 in the core?
by Donal K. Fellows other posts by this author
Apr 28 2008 1:16AM messages near this date
Re: [TCLCORE] [SPAM] [6.0] Re: base64 in the core?
|
Re: [TCLCORE] [SPAM] [6.0] Re: base64 in the core?
Larry McVoy wrote:
> Can you explain that a bit? I'm thinking something like
>
> when we detect a foreach (c in buf)
> bump the refcount on buf
> set an index at 0
> start the loop
> each iteration
> c = buf[index++]
> loop body
> decr refcount on c
> decr refcount on buf
>
> What's so hard about that? I realize I'm asking this naively so I'm not
> say "you wuss, go do it", I'm say "teach me why this is hard, please".
The problem is that lots of code has to be rewritten to understand
keeping a reference count on the buffer, or rather on the string rep[*].
We've done that in the past with other types (lists and dicts both work
this way) so that's not in itself a major problem, but it requires a
fair bit of coding as the current string code doesn't work like that
(and makes a number of assumptions about the bytes member of the Tcl_Obj
which would become false).
However, the experience with other language implementations indicates
that this sort of thing tends to mean that the large buffer hangs around
a lot longer (due to retained references) than the string it supposedly
was the backing for, and this increases the memory consumption of the
program a lot. I suspect a fair part of Java's memory hungriness is due
to this effect (coupled with the fact that garbage collection usually
ends up allocating more in the first place).
Given that the alternative is really simple coding, I really suggest
that people try the simple case first and see if that's good enough. We
can even go so far as to do caching so that single-character strings are
not inefficient, and the code/issues there aren't tricky. I like simple,
and try to go for it unless there's evidence it isn't good enough. :-)
Donal.
[* Some of our strings have internal representations that allow us to
process them much more efficiently. This was important for avoiding
the costs that would otherwise be incurred from using UTF-8, and was
the main way that we recovered from the slowdown in Tcl 8.1... ]
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Trevor Davel
Pat Thoyts
Kevin Kenny
Donal K. Fellows
Larry McVoy
Donal K. Fellows
Larry McVoy
Donal K. Fellows
Kevin Kenny
Donal K. Fellows
Larry McVoy
Donal K. Fellows
Alexandre Ferrieux
Lars Hellstrom
Donal K. Fellows
Alexandre Ferrieux
Donal K. Fellows
Alexandre Ferrieux
Donal K. Fellows
Alexandre Ferrieux
Larry McVoy
|