https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119965

--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
One of the issues is that IPA-CP considers the entire deepsjeng_r "small."
Its size is estimated to be 13154 which means that rather than allowing it
grow only by 10 % (param ipa-cp-unit-growth) it is allowed to grow by that
fraction of the smallest threshold 16000, so to 17600 which is 133.8% of
the original.

The idea of this threshold is that in a medium or large sized project a
fraction is good estimate by how much we can grow but in small ones a
useful cloning opportunity can easily mean we need to grow the code
relatively more.  The actual growth that we see is bigger which is probably
because inlining repeats a similar exercise on its own.

I have not actually experimented with this threshold.  To give you an idea,
these are the estimated "overall sizes" of spec 2017 rate benchmarks:

  lbm_r            2334
  mcf_r            2515
  bwaves_r         3582
  exchange2_r     10517
  leela_r         11241
  deepsjeng_r     13174
  xz_r            16059
  nab_r           16569
  fotonik3d_r     46247
  x264_r          68491
  roms_r          95064
  namd_r          97950
  povray_r       131335
  imagick_r      193636
  omnetpp_r      205954
  parest_r       290433
  perlbench_r    333210
  cpuxalan_r     495293
  cam4_r         515627
  cactusBSSN_r   570460
  blender_r     1391422
  cpugcc_r      1415608
  wrf_r         2439682

For the record, a recent PGO-LTO-bootstrapped cc1plus had estimated
overall_size 6095619 and clang-21 had 11622201.  I guess the above means we
could lower the threshold somewhat, but the effect would only be visible
for deepsjeng_r projects :-) Long-term the idea is to make the growth
relative only to the hot portion of the code in the PGO case.  That will
most likely make me re-evaluate the threshold too but it may make the
problem worse in some cases.

As far as the individual cloning benefit threshold is concerned, I'm afraid
deepsjeng_r is an outlier too.  I plan to increase it somewhat, but to make
a difference in deepsjeng_r we'd need to raise it above limits which are
currently necessary to get the benefits in other benchmarks (mcf_r and
exchange_r).  Unlike in the cases of the vast majority of benchmarks, with
PGO IPA-CP unfortunately (incorrectly) thinks cloning is a great idea.  The
following are the percentiles(*) of cloning evaluations in the benchmark, the
bigger the better:

    P  Evaluation  Abs size growth  Rel size growth
  ---  ----------  ---------------  ---------------
  Min        0.03            20579          156.45%
   5%        0.32            18761          142.63%
  10%        0.46            12589           95.70%
  15%        0.92            12577           95.61%
  20%        0.92            12577           95.61%
  25%        1.56            12135           92.25%
  30%        2.39            12125           92.18%
  35%        7.09            11957           90.90%
  40%      415.39            11675           88.76%
  45%      969.38            11663           88.67%
  50%     5103.64            11237           85.43%
  55%     6040.62            10996           83.59%
  60%     7174.10             9521           72.38%
  65%    1.65e+04             9164           69.67%
  70%    2.33e+04             8585           65.27%
  75%    1.11e+05             6751           51.32%
  80%    4.87e+05             6563           49.89%
  85%    8.24e+05             5735           43.60%
  90%    2.50e+06             5565           42.31%
  95%    3.86e+06             5409           41.12%
  Max    2.43e+07             3624           27.55%

(*) This is with a patch making the run-time evaluations relative to
overall run-time, a patch which I hoped to commit a month ago but which
still regresses x264_r for some reason.  But the numbers without it are
just scaled upwards quite a bit.

So we'd have to raise the threshold tremendously (to disallow all of
IPA-CP) which would switch it off almost everywhere.  I will try to have a
look what is the opportunity that the heuristics thinks is so fabulous.

In any event, I am looking into this, but deepsjeng_r is hopefully an
outlier in many regards.

Reply via email to