[Webkit-unassigned] [Bug 94810] Vector::shrinkToFit should use realloc when canCopyWithMemcpy is true

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 28 07:33:20 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=94810





--- Comment #8 from Yong Li <yoli at rim.com>  2012-08-28 07:33:22 PST ---
(In reply to comment #7)
> (From update of attachment 160738 [details])
> r- because you do not provide any rationale for making the change.
> 
> 1) Please microbenchmark this to provide numbers for the improvement.
> 2) Please find what is the memory impact. Exactly how does fastMalloc work with those Realloc.

OK

> 
> 
> > Also StringBuilder/StringImpl is using fastRealloc to shrink memory anyway.
> 
> This is pretty much irrelevant. The memory allocated there is small on average and the lost memory on shrink is at most a little less the size of the useful payload.

Isn't this the worst case of using realloc (causing fragments)? If the memory allocated isn't small, and realloc() would keep the address unchanged, it saves a memcpy on a large block. If realloc() uses different addresses, it is same as malloc/memcpy/free.

I understand this depends very much on the actual malloc algorithm. But what Vector is trying to do here is just a re-alloc. It is very natural to use realloc, and lets the malloc algorithm to decide what to do for best performance. Probably adding an ENABLE switch is better?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list