Bug 156152 - bmalloc: segregate small and large objects again, and allocate more objects on the small path
Summary: bmalloc: segregate small and large objects again, and allocate more objects o...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-03 17:55 PDT by Geoffrey Garen
Modified: 2016-04-04 00:47 PDT (History)
6 users (show)

See Also:


Attachments
Patch (40.41 KB, patch)
2016-04-03 18:31 PDT, Geoffrey Garen
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2016-04-03 17:55:39 PDT
bmalloc: segregate small and large objects again, and allocate more objects on the small path
Comment 1 Geoffrey Garen 2016-04-03 18:31:06 PDT
Created attachment 275519 [details]
Patch
Comment 2 WebKit Commit Bot 2016-04-03 18:32:14 PDT
Attachment 275519 [details] did not pass style-queue:


ERROR: Source/bmalloc/bmalloc/Heap.cpp:86:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/bmalloc/bmalloc/Heap.cpp:91:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/bmalloc/bmalloc/Heap.cpp:296:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/bmalloc/bmalloc/Heap.cpp:344:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/bmalloc/bmalloc/Heap.cpp:403:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 5 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Sam Weinig 2016-04-03 18:52:56 PDT
Comment on attachment 275519 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=275519&action=review

> Source/bmalloc/bmalloc/Chunk.h:92
> +        // The first few bytes of metadata cover the metadata region, so they're
> +        // not used. We can steal them to store m_objectType.
> +        ObjectType m_objectType;
> +
> +        // A chunk is either small or large for its lifetime, so we can union
> +        // small and large metadata, and then use one or the other at runtime.
> +        std::array<SmallPage, chunkSize / smallPageSize> m_pages;
> +        std::array<BoundaryTag, boundaryTagCount> m_boundaryTags;

This is neat, but it would be neater if there was an assertion that the object type never overlapped with anything interesting in m_pages or m_boundaryTags.
Comment 4 Geoffrey Garen 2016-04-03 22:21:33 PDT
> This is neat, but it would be neater if there was an assertion that the
> object type never overlapped with anything interesting in m_pages or
> m_boundaryTags.

I wrote this assertion and it demonstrated that we had two problems:

(1) Chunk::begin() would provide a pointer that wasn't physical-page-size-aligned on 16kB systems. All pages in this kind of chunk would fail to madvise. 

(2) If you changed things around so that the first page started at byte 0, which was physical-page-size-aligned, then you would collide with m_objectType.

I solved these problems by changing Chunk::begin() to round up to the physical page size, and keeping the first page starting at Chunk::begin(). This wastes a little metadata space on 16kB systems, but not a lot (1.5% vs 1.0%).
Comment 5 Geoffrey Garen 2016-04-03 22:26:37 PDT
Committed r198995: <http://trac.webkit.org/changeset/198995>
Comment 6 Benjamin Poulain 2016-04-04 00:47:22 PDT
From AreWeFastYet, it looks like this could be a 0.5% win on Sunspider.