Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Issue 2335193005: Release the buffer in StringBuilder::toString() and toAtomicString(). (Closed)

Created:
4 years, 3 months ago by esprehn
Modified:
4 years, 3 months ago
Reviewers:
haraken, jbroman
CC:
blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, Mikhail
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Release the buffer in StringBuilder::toString() and toAtomicString(). Various places in the code like FetchDataLoader and WorkerScriptLoader keep a StringBuilder as a data member to buffer data and then call toString() on it later. By clearing the buffer in the string conversion methods we avoid having two copies of the values in memory persistently. This restores the behavior from before I switched it to a Vector in https://codereview.chromium.org/2046353002 where toString() and toAtomicString() would always clear the buffer when converting to a string because they called reifyString. While I haven't been able to confirm this is the cause, this seems a possible candidate for the small regression on system health benchmarks. It's also just generally better behavior since it avoids an accidental 2x memory increase from a StringBuilder member. This also makes appending individual characters cheaper by removing the branch from resetting m_string every time. BUG=633197 Committed: https://crrev.com/e5dd14ac89435d384867f678106374f471dd414a Cr-Commit-Position: refs/heads/master@{#418437}

Patch Set 1 #

Patch Set 2 : Make m_string and m_buffer exclusive to each other. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -21 lines) Patch
M third_party/WebKit/Source/wtf/text/StringBuilder.h View 1 3 chunks +1 line, -3 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringBuilder.cpp View 1 8 chunks +20 lines, -18 lines 4 comments Download

Messages

Total messages: 16 (8 generated)
esprehn
4 years, 3 months ago (2016-09-13 22:37:48 UTC) #6
haraken
LGTM https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp File third_party/WebKit/Source/wtf/text/StringBuilder.cpp (right): https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp#newcode93 third_party/WebKit/Source/wtf/text/StringBuilder.cpp:93: void StringBuilder::clear() I'm just curious but would you ...
4 years, 3 months ago (2016-09-14 00:05:41 UTC) #8
esprehn
https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp File third_party/WebKit/Source/wtf/text/StringBuilder.cpp (right): https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp#newcode93 third_party/WebKit/Source/wtf/text/StringBuilder.cpp:93: void StringBuilder::clear() On 2016/09/14 at 00:05:41, haraken wrote: > ...
4 years, 3 months ago (2016-09-14 00:14:31 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2335193005/20001
4 years, 3 months ago (2016-09-14 00:20:32 UTC) #11
haraken
https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp File third_party/WebKit/Source/wtf/text/StringBuilder.cpp (right): https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp#newcode93 third_party/WebKit/Source/wtf/text/StringBuilder.cpp:93: void StringBuilder::clear() On 2016/09/14 00:14:31, esprehn wrote: > On ...
4 years, 3 months ago (2016-09-14 00:21:06 UTC) #12
esprehn
https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp File third_party/WebKit/Source/wtf/text/StringBuilder.cpp (right): https://codereview.chromium.org/2335193005/diff/20001/third_party/WebKit/Source/wtf/text/StringBuilder.cpp#newcode93 third_party/WebKit/Source/wtf/text/StringBuilder.cpp:93: void StringBuilder::clear() On 2016/09/14 at 00:21:05, haraken wrote: > ...
4 years, 3 months ago (2016-09-14 00:25:39 UTC) #13
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 3 months ago (2016-09-14 00:26:47 UTC) #14
commit-bot: I haz the power
4 years, 3 months ago (2016-09-14 00:29:49 UTC) #16
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/e5dd14ac89435d384867f678106374f471dd414a
Cr-Commit-Position: refs/heads/master@{#418437}

Powered by Google App Engine
This is Rietveld 408576698