[Webkit-unassigned] [Bug 187460] New: ResourceResponseBase wastes a lot of space because of std::optional<>

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 8 22:34:29 PDT 2018


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

            Bug ID: 187460
           Summary: ResourceResponseBase wastes a lot of space because of
                    std::optional<>
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Page Loading
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: simon.fraser at apple.com
                CC: beidson at apple.com

ResourceResponseBase layout looks like:

 45$ $ ./Tools/Scripts/dump-class-layout -c Release WebCore ResourceResponseBase
  +0 <568> ResourceResponseBase
  +0 < 48>     WebCore::URL m_url
  +0 <  8>         WTF::String m_string
  +0 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
  +0 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
  +8 <  1>       bool m_isValid : 1
  +8 <  1>       bool m_protocolIsInHTTPFamily : 1
  +8 <  1>       bool m_cannotBeABaseURL : 1
  +8 <  1>       <PADDING BITS: 5 bits>
  +9 <  3>       <PADDING: 3 bytes>
 +12 <  4>       unsigned int m_schemeEnd
 +16 <  4>       unsigned int m_userStart
 +20 <  4>       unsigned int m_userEnd
 +24 <  4>       unsigned int m_passwordEnd
 +28 <  4>       unsigned int m_hostEnd
 +32 <  4>       unsigned int m_portEnd
 +36 <  4>       unsigned int m_pathAfterLastSlash
 +40 <  4>       unsigned int m_pathEnd
 +44 <  4>       unsigned int m_queryEnd
 +48 <  8>     WTF::AtomicString m_mimeType
 +48 <  8>         WTF::String m_string
 +48 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
 +48 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
 +56 <  8>   long long m_expectedContentLength
 +64 <  8>     WTF::AtomicString m_textEncodingName
 +64 <  8>         WTF::String m_string
 +64 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
 +64 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
 +72 <  8>     WTF::AtomicString m_httpStatusText
 +72 <  8>         WTF::String m_string
 +72 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
 +72 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
 +80 <  8>     WTF::AtomicString m_httpVersion
 +80 <  8>         WTF::String m_string
 +80 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
 +80 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
 +88 < 32>     WebCore::HTTPHeaderMap m_httpHeaderFields
 +88 < 16>         WebCore::HTTPHeaderMap::CommonHeadersVector m_commonHeaders
 +88 < 16>             WTF::VectorBuffer<WebCore::HTTPHeaderMap::CommonHeader, 0> WTF::VectorBuffer<WebCore::HTTPHeaderMap::CommonHeader, 0>
 +88 < 16>                 WTF::VectorBufferBase<WebCore::HTTPHeaderMap::CommonHeader> WTF::VectorBufferBase<WebCore::HTTPHeaderMap::CommonHeader>
 +88 <  8>                   WebCore::HTTPHeaderMap::CommonHeader * m_buffer
 +96 <  4>                   unsigned int m_capacity
+100 <  4>                   unsigned int m_size
+104 < 16>         WebCore::HTTPHeaderMap::UncommonHeadersVector m_uncommonHeaders
+104 < 16>             WTF::VectorBuffer<WebCore::HTTPHeaderMap::UncommonHeader, 0> WTF::VectorBuffer<WebCore::HTTPHeaderMap::UncommonHeader, 0>
+104 < 16>                 WTF::VectorBufferBase<WebCore::HTTPHeaderMap::UncommonHeader> WTF::VectorBufferBase<WebCore::HTTPHeaderMap::UncommonHeader>
+104 <  8>                   WebCore::HTTPHeaderMap::UncommonHeader * m_buffer
+112 <  4>                   unsigned int m_capacity
+116 <  4>                   unsigned int m_size
+120 <240>     WebCore::NetworkLoadMetrics m_networkLoadMetrics
+120 <  8>         WTF::Seconds domainLookupStart
+120 <  8>           double m_value
+128 <  8>         WTF::Seconds domainLookupEnd
+128 <  8>           double m_value
+136 <  8>         WTF::Seconds connectStart
+136 <  8>           double m_value
+144 <  8>         WTF::Seconds secureConnectionStart
+144 <  8>           double m_value
+152 <  8>         WTF::Seconds connectEnd
+152 <  8>           double m_value
+160 <  8>         WTF::Seconds requestStart
+160 <  8>           double m_value
+168 <  8>         WTF::Seconds responseStart
+168 <  8>           double m_value
+176 <  8>         WTF::Seconds responseEnd
+176 <  8>           double m_value
+184 <  1>       bool complete
+185 <  7>       <PADDING: 7 bytes>
+192 <  8>         WTF::String protocol
+192 <  8>             WTF::RefPtr<WTF::StringImpl, WTF::DumbPtrTraits<WTF::StringImpl> > m_impl
+192 <  8>               WTF::DumbPtrTraits<WTF::StringImpl>::StorageType m_ptr
+200 < 16>         std::optional<WTF::String> remoteAddress
+200 < 16>             std::OptionalBase<WTF::String> std::OptionalBase<WTF::String>
+200 <  1>               bool init_
+201 <  7>               <PADDING: 7 bytes>
+208 <  8>               std::storage_t<WTF::String> storage_
+216 < 16>         std::optional<WTF::String> connectionIdentifier
+216 < 16>             std::OptionalBase<WTF::String> std::OptionalBase<WTF::String>
+216 <  1>               bool init_
+217 <  7>               <PADDING: 7 bytes>
+224 <  8>               std::storage_t<WTF::String> storage_
+232 <  8>         std::optional<WebCore::NetworkLoadPriority> priority
+232 <  8>             std::OptionalBase<WebCore::NetworkLoadPriority> std::OptionalBase<WebCore::NetworkLoadPriority>
+232 <  1>               bool init_
+233 <  3>               <PADDING: 3 bytes>
+236 <  4>               std::constexpr_storage_t<WebCore::NetworkLoadPriority> storage_
+240 < 40>         std::optional<WebCore::HTTPHeaderMap> requestHeaders
+240 < 40>             std::OptionalBase<WebCore::HTTPHeaderMap> std::OptionalBase<WebCore::HTTPHeaderMap>
+240 <  1>               bool init_
+241 <  7>               <PADDING: 7 bytes>
+248 < 32>               std::storage_t<WebCore::HTTPHeaderMap> storage_
+280 < 16>         std::optional<unsigned long long> requestHeaderBytesSent
+280 < 16>             std::OptionalBase<unsigned long long> std::OptionalBase<unsigned long long>
+280 <  1>               bool init_
+281 <  7>               <PADDING: 7 bytes>
+288 <  8>               std::constexpr_storage_t<unsigned long long> storage_
+296 < 16>         std::optional<unsigned long long> requestBodyBytesSent
+296 < 16>             std::OptionalBase<unsigned long long> std::OptionalBase<unsigned long long>
+296 <  1>               bool init_
+297 <  7>               <PADDING: 7 bytes>
+304 <  8>               std::constexpr_storage_t<unsigned long long> storage_
+312 < 16>         std::optional<unsigned long long> responseHeaderBytesReceived
+312 < 16>             std::OptionalBase<unsigned long long> std::OptionalBase<unsigned long long>
+312 <  1>               bool init_
+313 <  7>               <PADDING: 7 bytes>
+320 <  8>               std::constexpr_storage_t<unsigned long long> storage_
+328 < 16>         std::optional<unsigned long long> responseBodyBytesReceived
+328 < 16>             std::OptionalBase<unsigned long long> std::OptionalBase<unsigned long long>
+328 <  1>               bool init_
+329 <  7>               <PADDING: 7 bytes>
+336 <  8>               std::constexpr_storage_t<unsigned long long> storage_
+344 < 16>         std::optional<unsigned long long> responseBodyDecodedSize
+344 < 16>             std::OptionalBase<unsigned long long> std::OptionalBase<unsigned long long>
+344 <  1>               bool init_
+345 <  7>               <PADDING: 7 bytes>
+352 <  8>               std::constexpr_storage_t<unsigned long long> storage_
+360 < 24>     std::optional<WebCore::CertificateInfo> m_certificateInfo
+360 < 24>         std::OptionalBase<WebCore::CertificateInfo> std::OptionalBase<WebCore::CertificateInfo>
+360 <  1>           bool init_
+361 <  7>           <PADDING: 7 bytes>
+368 < 16>           std::storage_t<WebCore::CertificateInfo> storage_
+384 < 16>     std::optional<WTF::Seconds> m_age
+384 < 16>         std::OptionalBase<WTF::Seconds> std::OptionalBase<WTF::Seconds>
+384 <  1>           bool init_
+385 <  7>           <PADDING: 7 bytes>
+392 <  8>           std::constexpr_storage_t<WTF::Seconds> storage_
+400 < 16>     std::optional<WTF::WallTime> m_date
+400 < 16>         std::OptionalBase<WTF::WallTime> std::OptionalBase<WTF::WallTime>
+400 <  1>           bool init_
+401 <  7>           <PADDING: 7 bytes>
+408 <  8>           std::constexpr_storage_t<WTF::WallTime> storage_
+416 < 16>     std::optional<WTF::WallTime> m_expires
+416 < 16>         std::OptionalBase<WTF::WallTime> std::OptionalBase<WTF::WallTime>
+416 <  1>           bool init_
+417 <  7>           <PADDING: 7 bytes>
+424 <  8>           std::constexpr_storage_t<WTF::WallTime> storage_
+432 < 16>     std::optional<WTF::WallTime> m_lastModified
+432 < 16>         std::OptionalBase<WTF::WallTime> std::OptionalBase<WTF::WallTime>
+432 <  1>           bool init_
+433 <  7>           <PADDING: 7 bytes>
+440 <  8>           std::constexpr_storage_t<WTF::WallTime> storage_
+448 < 32>     WebCore::ParsedContentRange m_contentRange
+448 <  1>       bool m_isValid
+449 <  7>       <PADDING: 7 bytes>
+456 <  8>       int64_t m_firstBytePosition
+464 <  8>       int64_t m_lastBytePosition
+472 <  8>       int64_t m_instanceLength
+480 < 40>     WebCore::CacheControlDirectives m_cacheControlDirectives
+480 < 16>         std::optional<WTF::Seconds> maxAge
+480 < 16>             std::OptionalBase<WTF::Seconds> std::OptionalBase<WTF::Seconds>
+480 <  1>               bool init_
+481 <  7>               <PADDING: 7 bytes>
+488 <  8>               std::constexpr_storage_t<WTF::Seconds> storage_
+496 < 16>         std::optional<WTF::Seconds> maxStale
+496 < 16>             std::OptionalBase<WTF::Seconds> std::OptionalBase<WTF::Seconds>
+496 <  1>               bool init_
+497 <  7>               <PADDING: 7 bytes>
+504 <  8>               std::constexpr_storage_t<WTF::Seconds> storage_
+512 <  1>       bool noCache
+513 <  1>       bool noStore
+514 <  1>       bool mustRevalidate
+515 <  1>       bool immutable
+516 <  4>   <PADDING: 4 bytes>
+520 < 21>     std::optional<std::__1::array<unsigned char, 20> > m_cacheBodyKey
+520 < 21>         std::OptionalBase<std::__1::array<unsigned char, 20> > std::OptionalBase<std::__1::array<unsigned char, 20> >
+520 <  1>           bool init_
+521 < 20>           std::constexpr_storage_t<std::__1::array<unsigned char, 20> > storage_
+541 <  3>   <PADDING: 3 bytes>
+544 <  4>   WebCore::ResourceResponseBase::Source m_source
+548 <  4>   WebCore::ResourceResponseBase::Type m_type
+552 <  4>   WebCore::ResourceResponseBase::Tainting m_tainting
+556 <  4>   int m_httpStatusCode
+560 <  1>   bool m_isNull
+561 <  1>   bool m_haveParsedCacheControlHeader
+562 <  1>   bool m_haveParsedAgeHeader
+563 <  1>   bool m_haveParsedDateHeader
+564 <  1>   bool m_haveParsedExpiresHeader
+565 <  1>   bool m_haveParsedLastModifiedHeader
+566 <  1>   bool m_haveParsedContentRangeHeader
+567 <  1>   bool m_isRedirected
Total byte size: 568
Total pad bytes: 132
Padding percentage: 23.24 %

so it's a whopping 568 bytes about a quarter of which is wasted space. Each optional<WallTime> wastes 7 bytes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180709/2944f844/attachment.html>


More information about the webkit-unassigned mailing list