On Feb 1, 6:39 pm, Richard Newman <[email protected]> wrote:
> If you're adding a new TransientVector instance on every call to  
> conj!, you might as well just use conj.

I think not. The reason building a huge transient vector is faster
than building a huge persistent vector isn't the Vector instance
created by each conj, it's the multiple arrays of 32 references each
that it has to allocate and copy. My proposed change wouldn't do that,
it would just make a new, tiny object to hold onto the same mutating
arrays. If the vector is being built in a loop, it's possible escape
analysis would allow HotSpot to eliminate the allocation altogether.
Anyway, at this point it's just conjecture, which I was hoping to
motivate someone else to test, but it doesn't seem to have worked, so
I guess it's up to me to do the experiment ;)

> Making transients slower -- even by a small amount -- strikes me as  
> contrary to Rich's position.
....
> Making them safer is analogous to asking for checks to be added to  
> unchecked math operations.

You'd certainly be right if the slowdown means that transients aren't
still _much_ more efficient than persistent vectors. But it they're
still much faster, but not quite as fast as "unsafe" transients, then
I think the question is certainly debatable.

> You should *never* be shoving transients into vars, IMO.

Agreed. It was just easier to get the point across that way than with
a more complex (and real) example.

I'll post again when I have a patch and numbers to back up my
speculation.

- moss

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to