<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>279498</bug_id>
          
          <creation_ts>2024-09-11 01:13:16 -0700</creation_ts>
          <short_desc>REGRESSION (282580@main): 4.5MB binary size increase</short_desc>
          <delta_ts>2024-09-18 18:22:54 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=278244</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Antti Koivisto">koivisto</reporter>
          <assigned_to name="Sam Weinig">sam</assigned_to>
          <cc>cdumez</cc>
    
    <cc>darin</cc>
    
    <cc>g_squelart</cc>
    
    <cc>koivisto</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2059231</commentid>
    <comment_count>0</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2024-09-11 01:13:16 -0700</bug_when>
    <thetext>Apparently all the templates are generating way more code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059232</commentid>
    <comment_count>1</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2024-09-11 01:13:33 -0700</bug_when>
    <thetext>rdar://135344420</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059233</commentid>
    <comment_count>2</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2024-09-11 01:19:38 -0700</bug_when>
    <thetext>+4.5MB on WebCore
+4.5MB on WebCore_iosMac</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059307</commentid>
    <comment_count>3</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-11 09:09:57 -0700</bug_when>
    <thetext>Oof, that&apos;s quite a bit! Let me think if there is a good way to reduce this without a total re-do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059465</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-11 16:49:26 -0700</bug_when>
    <thetext>Took a little look at this, and it looks like the majority of the growth is in, of all places, the macho strings table.

Looking into this more, it seems there is a relatively well known issue with std::visit, at least as implemented by libc++.

A good resource, with links to other discussions and solutions is https://mpark.github.io/programming/2019/01/22/variant-visitation-v2/.

I&apos;m going to try using the mpark::variant/visitor (https://github.com/mpark/variant) for the CSSCalc code and see what effect that has on code size. There may end up being a more surgical fix, but this is an interesting first step.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059479</commentid>
    <comment_count>5</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-11 17:19:07 -0700</bug_when>
    <thetext>One additional link, https://github.com/llvm/llvm-project/issues/62648, is an issue tracked for libc++ on improving this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059488</commentid>
    <comment_count>6</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-11 17:28:14 -0700</bug_when>
    <thetext>Switching to mpark::variant reduced the total size change from:

  +4.2% +4.47Mi  +4.2% +4.47Mi    TOTAL

to

  +0.3%  +371Ki  +0.3%  +368Ki    TOTAL

Much more reasonable. (still a bit high, but not crazy).

Switch all of WebCore over to it would probably be a pretty substantial win.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059512</commentid>
    <comment_count>7</comment_count>
    <who name="Gerald Squelart">g_squelart</who>
    <bug_when>2024-09-11 18:11:01 -0700</bug_when>
    <thetext>(Passer-by thought, please ignore if N/A)

Is the size regression mainly due to std::visit?
If yes, would it be possible to only change WTF::switchOn (which is used 6-7 times more often than naked std::visit) to accomplish most of the gains of mpark&apos;s re-implementation?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059678</commentid>
    <comment_count>8</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-12 08:00:55 -0700</bug_when>
    <thetext>(In reply to Gerald Squelart from comment #7)
&gt; (Passer-by thought, please ignore if N/A)
&gt; 
&gt; Is the size regression mainly due to std::visit?
&gt; If yes, would it be possible to only change WTF::switchOn (which is used 6-7
&gt; times more often than naked std::visit) to accomplish most of the gains of
&gt; mpark&apos;s re-implementation?

Yeah, that was what I meant to imply with &quot;a more surgical fix&quot;. I was hoping I could just call mpark::visit(), and pass it a std::variant, but that doesn&apos;t work, so will need to lift the implementation up and refactor it so it can work with std::variant, which is doable, but a bit tricky.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2059679</commentid>
    <comment_count>9</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-12 08:02:27 -0700</bug_when>
    <thetext>(I guess the unstated thing here is that switching to use mpark::variant for the calc code was a much easier test than refactoring WTF::switchOn, so that&apos;s why I did that as the test).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2060479</commentid>
    <comment_count>10</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2024-09-16 10:48:19 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/33706</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2060879</commentid>
    <comment_count>11</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-09-17 16:14:29 -0700</bug_when>
    <thetext>Committed 283806@main (6aa472c27a8a): &lt;https://commits.webkit.org/283806@main&gt;

Reviewed commits have been landed. Closing PR #33706 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2061292</commentid>
    <comment_count>12</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-09-18 18:22:54 -0700</bug_when>
    <thetext>Committed 283286.87@safari-7620-branch (cf65dbb69374): &lt;https://commits.webkit.org/283286.87@safari-7620-branch&gt;

Reviewed commits have been landed. Closing PR #1838 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>