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

Issue 3329019: Dynamically determine optimal instance size.... (Closed)

Created:
10 years, 3 months ago by Vladislav Kaznacheev
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Dynamically determine optimal instance size. The number of inobject properties used to be derived from the number of this property assignments in the constructor (and increased by 2 to allow for properties added later). This very often leads to wasted inobject slots. This patch reclaims some of the unused inobject space by the following method: - for each constructor function the first several objects are allocated using the initial ("generous) instance size estimation (this is called 'tracking phase'). - during the tracking phase map transitions are tracked and actual property counts are collected. - at the end of the tracking phase instance sizes in the maps are decreased if necessary (starting with the function's initial map and traversing the transition tree). - all further allocation use more realistic instance size estimation. Shrinking generously allocated objects without costly heap traversal is made possible by initializing their inobject properties with one_pointer_filler_map (instead of undefined). The initial slack for the generous allocation is increased from 2 to 6 which really helps some tests. Committed: http://code.google.com/p/v8/source/detail?r=5510

Patch Set 1 #

Total comments: 60

Patch Set 2 : '' #

Total comments: 26

Patch Set 3 : '' #

Total comments: 2

Patch Set 4 : '' #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+556 lines, -63 lines) Patch
M src/arm/builtins-arm.cc View 1 2 3 11 chunks +49 lines, -16 lines 0 comments Download
M src/builtins.h View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M src/handles.cc View 1 2 3 2 chunks +20 lines, -5 lines 0 comments Download
M src/heap.cc View 1 2 3 4 chunks +21 lines, -10 lines 0 comments Download
M src/ia32/assembler-ia32.h View 1 2 3 1 chunk +1 line, -0 lines 2 comments Download
M src/ia32/assembler-ia32.cc View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
M src/ia32/builtins-ia32.cc View 1 2 3 4 chunks +38 lines, -4 lines 0 comments Download
M src/mark-compact.cc View 3 3 chunks +18 lines, -4 lines 2 comments Download
M src/objects.h View 1 2 3 10 chunks +121 lines, -4 lines 2 comments Download
M src/objects.cc View 1 2 3 3 chunks +143 lines, -2 lines 2 comments Download
M src/objects-inl.h View 1 2 3 4 chunks +51 lines, -2 lines 0 comments Download
M src/runtime.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/runtime.cc View 1 2 3 4 chunks +42 lines, -11 lines 4 comments Download
M src/x64/builtins-x64.cc View 1 2 3 4 chunks +38 lines, -4 lines 0 comments Download
M test/cctest/test-api.cc View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 12 (0 generated)
Vladislav Kaznacheev
10 years, 3 months ago (2010-09-10 09:18:15 UTC) #1
Vladislav Kaznacheev
This is almost ready for commit with two exceptions: - I am going to add ...
10 years, 3 months ago (2010-09-10 09:29:42 UTC) #2
Mads Ager (chromium)
I like this idea. It is fairly simple and the shrinking of objects without actually ...
10 years, 3 months ago (2010-09-10 12:07:13 UTC) #3
antonm
Pretty neat http://codereview.chromium.org/3329019/diff/1/8 File src/ia32/builtins-ia32.cc (right): http://codereview.chromium.org/3329019/diff/1/8#newcode191 src/ia32/builtins-ia32.cc:191: // To allow for truncation nit: missing ...
10 years, 3 months ago (2010-09-10 15:28:50 UTC) #4
Vitaly Repeshko
A few more comments. http://codereview.chromium.org/3329019/diff/1/10 File src/objects.cc (right): http://codereview.chromium.org/3329019/diff/1/10#newcode5434 src/objects.cc:5434: set_inobject_slack_estimation(unused_inobject_properties); If unused_inobject_properties is 0, ...
10 years, 3 months ago (2010-09-14 13:24:00 UTC) #5
Vladislav Kaznacheev
I have solved the problem with GC hitting while the inobject slack tracking is in ...
10 years, 3 months ago (2010-09-20 17:26:59 UTC) #6
antonm
http://codereview.chromium.org/3329019/diff/15001/16001 File src/arm/builtins-arm.cc (right): http://codereview.chromium.org/3329019/diff/15001/16001#newcode693 src/arm/builtins-arm.cc:693: } // Otherwise r7 already holds undefined. might be ...
10 years, 3 months ago (2010-09-21 11:48:55 UTC) #7
Vladislav Kaznacheev
Added missing mark-compact.cc. http://codereview.chromium.org/3329019/diff/15001/16001 File src/arm/builtins-arm.cc (right): http://codereview.chromium.org/3329019/diff/15001/16001#newcode693 src/arm/builtins-arm.cc:693: } // Otherwise r7 already holds ...
10 years, 3 months ago (2010-09-21 12:32:40 UTC) #8
antonm
LGTM, but I don't quite understand why you reserve disassembler for a separate change, I'd ...
10 years, 3 months ago (2010-09-21 16:49:00 UTC) #9
Vladislav Kaznacheev
Addressed comments, waiting for Vitaly's LGTM. http://codereview.chromium.org/3329019/diff/15001/16007 File src/ia32/builtins-ia32.cc (right): http://codereview.chromium.org/3329019/diff/15001/16007#newcode193 src/ia32/builtins-ia32.cc:193: __ mov(edx, Factory::one_pointer_filler_map()); ...
10 years, 3 months ago (2010-09-22 11:33:06 UTC) #10
Vitaly Repeshko
LGTM with a few extra comments. http://codereview.chromium.org/3329019/diff/40001/39007 File src/ia32/assembler-ia32.h (right): http://codereview.chromium.org/3329019/diff/40001/39007#newcode598 src/ia32/assembler-ia32.h:598: void dec_b(const Operand& ...
10 years, 3 months ago (2010-09-22 14:40:25 UTC) #11
Vladislav Kaznacheev
10 years, 3 months ago (2010-09-23 08:38:16 UTC) #12
Addressed the comments. Submitting.

Thanks for the comments, everyone!

http://codereview.chromium.org/3329019/diff/40001/39007
File src/ia32/assembler-ia32.h (right):

http://codereview.chromium.org/3329019/diff/40001/39007#newcode598
src/ia32/assembler-ia32.h:598: void dec_b(const Operand& dst);
Will add support in a separate patch.

On 2010/09/22 14:40:25, Vitaly wrote:
> Does the disassembler support this already? If not, please extend it (and also
> test-disasm-ia32).

http://codereview.chromium.org/3329019/diff/40001/39009
File src/mark-compact.cc (right):

http://codereview.chromium.org/3329019/diff/40001/39009#newcode1151
src/mark-compact.cc:1151: if (map->IsMarked() &&
map->attached_to_shared_function_info()) {
On 2010/09/22 14:40:25, Vitaly wrote:
> This needs a short comment.

Done.

http://codereview.chromium.org/3329019/diff/40001/39011
File src/objects.cc (right):

http://codereview.chromium.org/3329019/diff/40001/39011#newcode5516
src/objects.cc:5516: set_expected_nof_properties(expected_nof_properties() -
slack);
On 2010/09/22 14:40:25, Vitaly wrote:
> Assert expected_nof_properties() - slack >= 0?

Done.

http://codereview.chromium.org/3329019/diff/40001/39012
File src/objects.h (right):

http://codereview.chromium.org/3329019/diff/40001/39012#newcode3499
src/objects.h:3499: // - The constructor is called from another context.
On 2010/09/22 14:40:25, Vitaly wrote:
> As we discussed this probably applies also to the case when a few closures
from
> a single context share a SharedFunctionInfo. If yes, please update the
comment.

Done.

http://codereview.chromium.org/3329019/diff/40001/39013
File src/runtime.cc (right):

http://codereview.chromium.org/3329019/diff/40001/39013#newcode6282
src/runtime.cc:6282: static void SetInlineConstructStub(Handle<JSFunction>
function) {
renamed to TrySettingInlineConstructStub

On 2010/09/22 14:40:25, Vitaly wrote:
> This name is misleading. It makes the reader think an inline stub
> unconditionally set. Consider adding "IfPossible" suffix or "Maybe" prefix.

http://codereview.chromium.org/3329019/diff/40001/39013#newcode6380
src/runtime.cc:6380: // If the constructor isn't a proper function we throw a
type error.
I got confused when fuzz natives test failed on this function. Simplified.
On 2010/09/22 14:40:25, Vitaly wrote:
> Why do have to throw this specific error? Why can't CONVERT_ARG_CHECKED be
used
> here? If there is a reason, please update the comment.

Powered by Google App Engine
This is Rietveld 408576698