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

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14466</bug_id>
          
          <creation_ts>2021-07-01 16:01:21 +0000</creation_ts>
          <short_desc>python: Should we add this optimization: -fno-semantic-interposition for 1.3x speed improvment?</short_desc>
          <delta_ts>2023-10-23 20:45:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>3.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>4.3 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Randy MacLeod">randy.macleod</reporter>
          <assigned_to name="Trevor Gamblin">tgamblin</assigned_to>
          <cc>marek.vasut</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>raj.khem</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>tgamblin</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90829</commentid>
    <comment_count>0</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-07-01 16:01:21 +0000</bug_when>
    <thetext>The Fedora packaging has been modified to compile libpython with -fno-semantic-interposition flag: it makes Python up to 1.3x faster without having to touch any line of the C code! Should we do the same?
   https://bugs.python.org/issue38980

From a recent build, it seems that flag is not used:

$ rgrep no-semantic-interposition tmp-glibc/work/core2-64-wrs-linux/python3/3.9.2-r0
$ echo &quot;No hits&quot;

Trevor has expressed interest in this but I didn&apos;t want it to get lost so I&apos;ve created this enhancement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90832</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-07-01 21:40:24 +0000</bug_when>
    <thetext>You may want to read https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition first and then see whether visibility settings might be safer?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90837</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-07-02 06:28:58 +0000</bug_when>
    <thetext>It is probably ok to enable this for an individual recipe, we just need to comment why and explain tit means library intercept/replacement won&apos;t work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90881</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-07-08 14:38:33 +0000</bug_when>
    <thetext>It will break things if we do it on python-native so only sdk and target.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95752</commentid>
    <comment_count>4</comment_count>
    <who name="Trevor Gamblin">tgamblin</who>
    <bug_when>2023-06-20 11:57:01 +0000</bug_when>
    <thetext>python3 ptest durations without the flag added to the recipe:

root@qemux86-64:~# grep -r &quot;Total duration&quot;
python3-ptest-time-1.log:Total duration: 22 min 37 sec
python3-ptest-time-2.log:Total duration: 24 min
python3-ptest-time-4.log:Total duration: 23 min 17 sec
python3-ptest-time-5.log:Total duration: 22 min 33 sec
python3-ptest-time-3.log:Total duration: 30 min 3 sec
root@qemux86-64:~# 

python3 ptest durations with -fno-semantic-interposition added to CPPFLAGS:

root@qemux86-64:~# grep -r &quot;Total duration&quot;
python3-ptest-with-opt-2.log:Total duration: 22 min 5 sec
python3-ptest-with-opt-4.log:Total duration: 22 min 30 sec
python3-ptest-with-opt-1.log:Total duration: 22 min 11 sec
python3-ptest-with-opt-3.log:Total duration: 22 min 36 sec
python3-ptest-with-opt-5.log:Total duration: 22 min 14 sec
root@qemux86-64:~# 

This doesn&apos;t seem like a worthwhile change, but I&apos;ll keep looking to see if it manifests more meaningfully in other areas.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95758</commentid>
    <comment_count>5</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2023-06-20 18:19:33 +0000</bug_when>
    <thetext>I agree, gains seems minimal

I think python 3.13 is doing some useful work in this regard

https://github.com/faster-cpython/ideas/blob/main/3.13/README.md

but it wont be available until 2024</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95775</commentid>
    <comment_count>6</comment_count>
    <who name="Trevor Gamblin">tgamblin</who>
    <bug_when>2023-06-21 13:48:26 +0000</bug_when>
    <thetext>Closing this for now as it doesn&apos;t seem to provide a meaningful gain to target builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95776</commentid>
    <comment_count>7</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-06-21 14:32:13 +0000</bug_when>
    <thetext>Thanks for checking on this again Trevor.

I don&apos;t expect to see much of a difference in ptest results.
It would be interesting to see if there&apos;s a difference in https://github.com/python/pyperformance as mentioned in:
https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup

but you likely have better things to do...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95777</commentid>
    <comment_count>8</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-06-21 15:57:51 +0000</bug_when>
    <thetext>In case you or someone else decides to test pyperformance, note that it is part of the  phoronix-test-suite but I don&apos;t know if it&apos;s build by default.
There&apos;s current isn&apos;t a pyperformance recipe.

tmp-glibc/work/core2-64-wrs-linux/phoronix-test-suite/10.8.4-r0/phoronix-test-suite/ob-cache/test-profiles/pts/pyperformance-1.0.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95778</commentid>
    <comment_count>9</comment_count>
    <who name="Trevor Gamblin">tgamblin</who>
    <bug_when>2023-06-21 18:55:06 +0000</bug_when>
    <thetext>It doesn&apos;t appear to be installed with phoronix by default. I wrote a standalone recipe for pyperformance, but after getting all of the dependencies sorted, along with providing enough extra storage and a nameserver in /etc/resolv.conf (part of the benchmark setup involves creating a venv and installing packages with pip, even if you have the dependencies in the image), the benchmark ran for a while and then stalled. Not sure what to make of it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96772</commentid>
    <comment_count>10</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2023-10-23 20:45:07 +0000</bug_when>
    <thetext>gcc has enabled this option now as part of -Ofast with

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=458d2c689963d8461d84670a3d8988cd6ecbfd81

Therefore it would be interesting to see if we change SELECTED_OPTIMIZATIONS from -O2 to -Ofast for python and cpython recipes, we might get some interesting results.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>