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

Issue 2859313003: Blink class layout optimization to reduce memory usage (Closed)

Created:
3 years, 7 months ago by stanisc
Modified:
3 years, 7 months ago
Reviewers:
chrishtr, yhirano
CC:
ajuma+watch_chromium.org, blink-reviews, blink-reviews-platform-graphics_chromium.org, Rik, chromium-reviews, dshwang, drott+blinkwatch_chromium.org, krit, fmalita+watch_chromium.org, Justin Novosad, kinuko+watch, pdr+graphicswatchlist_chromium.org, rwlbuis, Stephen Chennney
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Blink class layout optimization to reduce memory usage This change optimizes class layout on 64-bit in 4 blink classes, all related to images. Considering the 16 bit allocation granularity this saves 16 bytes per instance of each class. It looks like a typical web page might have up to a few hundred instances of each class so the total memory saving ~ 16-32 KB per Renderer process, potentially more for image heavy pages. UPDATE: crrev.com/2746343002 added a new field to ImageResourceContent which further increased it size by 8 bytes. I've moved the fields around again to still make it squeeze into 80 bytes. Layout details: Before: class blink::Image [sizeof = 40] : public WTF::ThreadSafeRefCounted<blink::Image> { vfptr +0x00 [sizeof=8] base +0x08 [sizeof=4] WTF::ThreadSafeRefCounted<blink::Image> <padding> (4 bytes) data +0x10 [sizeof=8] WTF::RefPtr<blink::SharedBuffer> encoded_image_data_ data +0x18 [sizeof=8] blink::UntracedMember<blink::ImageObserver> image_observer_ data +0x20 [sizeof=1] bool image_observer_disabled_ <padding> (7 bytes) } After: class blink::Image [sizeof = 32] : public WTF::ThreadSafeRefCounted<blink::Image> { vfptr +0x00 [sizeof=8] base +0x08 [sizeof=4] WTF::ThreadSafeRefCounted<blink::Image> data +0x0c [sizeof=1] bool image_observer_disabled_ <padding> (3 bytes) data +0x10 [sizeof=8] WTF::RefPtr<blink::SharedBuffer> encoded_image_data_ data +0x18 [sizeof=8] blink::UntracedMember<blink::ImageObserver> image_observer_ } Before: class blink::BitmapImage [sizeof = 280] : public blink::Image { base +0x00 [sizeof=33] blink::Image <padding> (7 bytes) data +0x28 [sizeof=112] blink::ImageSource source_ data +0x98 [sizeof=8] blink::IntSize size_ data +0xa0 [sizeof=8] blink::IntSize size_respecting_orientation_ data +0xa8 [sizeof=8] unsigned __int64 current_frame_ data +0xb0 [sizeof=40] WTF::Vector<blink::FrameData,1,WTF::PartitionAllocator> frames_ data +0xd8 [sizeof=8] sk_sp<SkImage> cached_frame_ data +0xe0 [sizeof=8] unsigned __int64 cached_frame_index_ data +0xe8 [sizeof=8] std::unique_ptr<...> frame_timer_ data +0xf0 [sizeof=4] int repetition_count_ data +0xf4 [sizeof=4] blink::BitmapImage::RepetitionCountStatus repetition_count_status_ data +0xf8 [sizeof=4] int repetitions_complete_ <padding> (4 bytes) data +0x100 [sizeof=8] double desired_frame_start_time_ data +0x108 [sizeof=8] unsigned __int64 frame_count_ data +0x110 [sizeof=4] blink::ImageAnimationPolicy animation_policy_ data +0x114 [sizeof=1] bool animation_finished_ : 1 data +0x114 [sizeof=1] bool all_data_received_ : 1 data +0x114 [sizeof=1] bool have_size_ : 1 data +0x114 [sizeof=1] bool size_available_ : 1 data +0x114 [sizeof=1] bool have_frame_count_ : 1 <padding> (3 bytes) } After: class blink::BitmapImage [sizeof = 264] : public blink::Image { base +0x00 [sizeof=32] blink::Image data +0x20 [sizeof=112] blink::ImageSource source_ data +0x90 [sizeof=8] blink::IntSize size_ data +0x98 [sizeof=8] blink::IntSize size_respecting_orientation_ data +0xa0 [sizeof=8] unsigned __int64 current_frame_ data +0xa8 [sizeof=40] WTF::Vector<blink::FrameData,1,WTF::PartitionAllocator> frames_ data +0xd0 [sizeof=8] sk_sp<SkImage> cached_frame_ data +0xd8 [sizeof=8] unsigned __int64 cached_frame_index_ data +0xe0 [sizeof=8] std::unique_ptr<...> frame_timer_ data +0xe8 [sizeof=4] blink::ImageAnimationPolicy animation_policy_ data +0xec [sizeof=1] bool animation_finished_ : 1 data +0xec [sizeof=1] bool all_data_received_ : 1 data +0xec [sizeof=1] bool have_size_ : 1 data +0xec [sizeof=1] bool size_available_ : 1 data +0xec [sizeof=1] bool have_frame_count_ : 1 data +0xed [sizeof=1] blink::BitmapImage::RepetitionCountStatus repetition_count_status_ <padding> (2 bytes) data +0xf0 [sizeof=4] int repetition_count_ data +0xf4 [sizeof=4] int repetitions_complete_ data +0xf8 [sizeof=8] double desired_frame_start_time_ data +0x100 [sizeof=8] unsigned __int64 frame_count_ } Before: class blink::ImageResourceContent [sizeof = 96] : public blink::GarbageCollectedFinalized<blink::ImageResourceContent> , public blink::ImageObserver { base +0x00 [sizeof=8] blink::ImageObserver base +0x08 [sizeof=1] blink::GarbageCollectedFinalized<blink::ImageResourceContent> <padding> (7 bytes) data +0x10 [sizeof=8] blink::Member<blink::ImageResourceInfo> info_ data +0x18 [sizeof=4] blink::ResourceStatus content_status_ <padding> (4 bytes) data +0x20 [sizeof=8] WTF::RefPtr<blink::Image> image_ data +0x28 [sizeof=24] WTF::HashCountedSet<...> observers_ data +0x40 [sizeof=24] WTF::HashCountedSet<...> finished_observers_ data +0x58 [sizeof=4] blink::Image::SizeAvailability size_available_ data +0x5C [sizeof=1] bool is_refetchable_data_from_disk_cache_ data +0x5D [sizeof=1] bool is_add_remove_observer_prohibited_ <padding> (2 bytes) } After: class blink::ImageResourceContent [sizeof = 80] : public blink::GarbageCollectedFinalized<blink::ImageResourceContent> , public blink::ImageObserver { base +0x00 [sizeof=8] blink::ImageObserver base +0x08 [sizeof=1] blink::GarbageCollectedFinalized<blink::ImageResourceContent> data +0x09 [sizeof=1] blink::ResourceStatus content_status_ data +0x0a [sizeof=1] bool is_refetchable_data_from_disk_cache_ data +0x0b [sizeof=1] bool is_add_remove_observer_prohibited_ data +0x0c [sizeof=4] blink::Image::SizeAvailability size_available_ data +0x10 [sizeof=8] blink::Member<blink::ImageResourceInfo> info_ data +0x18 [sizeof=8] WTF::RefPtr<blink::Image> image_ data +0x20 [sizeof=24] WTF::HashCountedSet<...> observers_ data +0x38 [sizeof=24] WTF::HashCountedSet<...> finished_observers_ } Before: class blink::DeferredImageDecoder [sizeof = 96] { data +0x00 [sizeof=8] std::unique_ptr<...> rw_buffer_ data +0x08 [sizeof=1] bool all_data_received_ <padding> (7 bytes) data +0x10 [sizeof=8] std::unique_ptr<...> actual_decoder_ data +0x18 [sizeof=8] WTF::String filename_extension_ data +0x20 [sizeof=8] blink::IntSize size_ data +0x28 [sizeof=4] int repetition_count_ data +0x2c [sizeof=1] bool has_embedded_color_space_ <padding> (3 bytes) data +0x30 [sizeof=8] sk_sp<SkColorSpace> color_space_for_sk_images_ data +0x38 [sizeof=1] bool can_yuv_decode_ data +0x39 [sizeof=1] bool has_hot_spot_ <padding> (2 bytes) data +0x3c [sizeof=8] blink::IntPoint hot_spot_ <padding> (4 bytes) data +0x48 [sizeof=16] WTF::Vector<...> frame_data_ data +0x58 [sizeof=8] WTF::RefPtr<...> frame_generator_ } After: class blink::DeferredImageDecoder [sizeof = 80] { data +0x00 [sizeof=8] std::unique_ptr<...> rw_buffer_ data +0x08 [sizeof=8] std::unique_ptr<...> actual_decoder_ data +0x10 [sizeof=8] WTF::String filename_extension_ data +0x18 [sizeof=8] blink::IntSize size_ data +0x20 [sizeof=4] int repetition_count_ data +0x24 [sizeof=1] bool has_embedded_color_space_ data +0x25 [sizeof=1] bool all_data_received_ data +0x26 [sizeof=1] bool can_yuv_decode_ data +0x27 [sizeof=1] bool has_hot_spot_ data +0x28 [sizeof=8] sk_sp<SkColorSpace> color_space_for_sk_images_ data +0x30 [sizeof=8] blink::IntPoint hot_spot_ data +0x38 [sizeof=16] WTF::Vector<...> frame_data_ data +0x48 [sizeof=8] WTF::RefPtr<...> frame_generator_ } BUG=710933 Review-Url: https://codereview.chromium.org/2859313003 Cr-Commit-Position: refs/heads/master@{#470373} Committed: https://chromium.googlesource.com/chromium/src/+/4f54bee9b89dd593c338dbc684f806bb73b48256

Patch Set 1 #

Patch Set 2 : Fix build error #

Patch Set 3 : Resolved merge conflict and changed blink::ResourceStatus enum to be based on uint8_t #

Messages

Total messages: 34 (24 generated)
stanisc
PTAL!
3 years, 7 months ago (2017-05-05 21:13:59 UTC) #11
chrishtr
lgtm
3 years, 7 months ago (2017-05-05 22:34:02 UTC) #12
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/2859313003/20001
3 years, 7 months ago (2017-05-06 00:13:18 UTC) #14
commit-bot: I haz the power
Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-generic_chromium_compile_only_ng/builds/333692)
3 years, 7 months ago (2017-05-06 19:24:50 UTC) #16
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/2859313003/20001
3 years, 7 months ago (2017-05-08 20:50:09 UTC) #18
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/413478) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, ...
3 years, 7 months ago (2017-05-08 20:53:37 UTC) #20
stanisc
+ yhirano@chromium.org for third_party/WebKit/Source/platform/loader/fetch/ResourceStatus.h
3 years, 7 months ago (2017-05-09 00:15:29 UTC) #25
yhirano
On 2017/05/09 00:15:29, stanisc wrote: > + mailto:yhirano@chromium.org for > third_party/WebKit/Source/platform/loader/fetch/ResourceStatus.h platform/loader lgtm
3 years, 7 months ago (2017-05-09 04:17:56 UTC) #28
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/2859313003/40001
3 years, 7 months ago (2017-05-09 17:29:57 UTC) #31
commit-bot: I haz the power
3 years, 7 months ago (2017-05-09 17:48:36 UTC) #34
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/4f54bee9b89dd593c338dbc684f8...

Powered by Google App Engine
This is Rietveld 408576698