<?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>6444</bug_id>
          
          <creation_ts>2014-06-13 11:40:49 +0000</creation_ts>
          <short_desc>Move on target kernel module support to separate recipe? (Improve Performance and developer experience)</short_desc>
          <delta_ts>2015-04-30 15:27:46 +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>kernel</component>
          <version>1.7</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>1.8</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Darren Hart">dvhart</assigned_to>
          <cc>alexandru.c.georgescu</cc>
    
    <cc>bruce.ashfield</cc>
    
    <cc>costin.c.constantin</cc>
    
    <cc>georgex.l.musat</cc>
    
    <cc>nitin.a.kamble</cc>
    
    <cc>tom.zanussi</cc>
          
          <qa_contact name="Alexandru Georgescu">alexandru.c.georgescu</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>43917</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 11:40:49 +0000</bug_when>
    <thetext>We pay a huge performance cost for allowing module builds in the main kernel recipe.

I&apos;d like to consider the idea of separating out the module build support into a separate kernel build. This would mean two different kernel unpack loops but would mean the main kernel recipe should build much faster and its sstate footprint would be much lower. The pain is then put onto the people using the external modules either on target or as separate recipes.

I&apos;m open to opinions on this but thought I&apos;d at least file the idea...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43922</commentid>
    <comment_count>1</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2014-06-13 13:00:03 +0000</bug_when>
    <thetext>When I looked into this in the past, the idea also crossed my mind.

A few clarifying points/questions:
  
  - The kernel module build itself is fast (in my builds), but the packaging is not.

  - Would an optional (emphasis on optional) single kernel-modules package (versus the current many packages
    that are pulled in via the kernel-modules package RDEPENDS) speed things up ? In my test it did show some
    promise. It could PROVIDE all the individual module packages to keep compatibility with existing recipes RDEPENDS.

  - If you don&apos;t do a single large kernel module build, I was benchmarking the packaging process and saw a 5 or 6 
    minute delay when a single do_package_split() was called.  Has anyone else seen similar in their benchmarking ?
    If that really is so expensive, is there a way to streamline it ? The thousands of files in the kernel tree seem to be
    triggering the pathalogical and really expensive cost of the operations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43923</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 13:12:02 +0000</bug_when>
    <thetext>If you look into where the kernel build spends its time, its the *huge* kernel-dev package and sstate files that actually cause the problems. If we ditch the &quot;external module&quot; pieces, I suspect you will be pleasantly surprised how fast it builds. The many small modules are not the speed bottleneck, at least in any measurement I&apos;ve ever made (and I have made some so I know what I&apos;m talking about here).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43935</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 13:38:31 +0000</bug_when>
    <thetext>Before:

1386.73user 263.17system 8:53.65elapsed 309%CPU (0avgtext+0avgdata 783288maxresident)k
195600inputs+11697048outputs (812major+60094900minor)pagefaults 0swaps

do_bundle_initramfs: Elapsed time: 0.04 seconds 
do_clean: Elapsed time: 8.53 seconds 
do_cleansstate: Elapsed time: 0.53 seconds 
do_compile: Elapsed time: 74.53 seconds 
do_compile_kernelmodules: Elapsed time: 22.09 seconds 
do_configure: Elapsed time: 0.87 seconds 
do_deploy: Elapsed time: 18.95 seconds 
do_fetch: Elapsed time: 0.07 seconds 
do_install: Elapsed time: 26.43 seconds 
do_kernel_checkout: Elapsed time: 4.43 seconds 
do_kernel_configcheck: Elapsed time: 5.61 seconds 
do_kernel_configme: Elapsed time: 12.61 seconds 
do_kernel_link_vmlinux: Elapsed time: 0.04 seconds 
do_package: Elapsed time: 152.61 seconds 
do_packagedata: Elapsed time: 0.59 seconds 
do_package_write_rpm: Elapsed time: 128.54 seconds 
do_patch: Elapsed time: 26.33 seconds 
do_populate_lic: Elapsed time: 0.25 seconds 
do_populate_sysroot: Elapsed time: 7.06 seconds 
do_sizecheck: Elapsed time: 0.03 seconds 
do_strip: Elapsed time: 0.03 seconds 
do_uboot_mkimage: Elapsed time: 0.03 seconds 
do_unpack: Elapsed time: 45.56 seconds 
do_validate_branches: Elapsed time: 10.59 seconds 

After:

1196.84user 187.46system 5:02.99elapsed 456%CPU (0avgtext+0avgdata 782904maxresident)k
392inputs+11470416outputs (0major+53738114minor)pagefaults 0swaps

 do_bundle_initramfs: Elapsed time: 0.03 seconds 
 do_compile: Elapsed time: 72.73 seconds 
 do_compile_kernelmodules: Elapsed time: 21.09 seconds 
 do_configure: Elapsed time: 0.90 seconds 
 do_deploy: Elapsed time: 17.00 seconds 
 do_fetch: Elapsed time: 0.05 seconds 
 do_install: Elapsed time: 3.76 seconds 
 do_kernel_checkout: Elapsed time: 4.34 seconds 
 do_kernel_configcheck: Elapsed time: 5.50 seconds 
 do_kernel_configme: Elapsed time: 12.00 seconds 
 do_kernel_link_vmlinux: Elapsed time: 0.03 seconds 
 do_package: Elapsed time: 34.22 seconds 
 do_packagedata: Elapsed time: 2.74 seconds 
 do_package_write_rpm: Elapsed time: 43.92 seconds 
 do_patch: Elapsed time: 25.61 seconds 
 do_populate_lic: Elapsed time: 0.25 seconds 
 do_populate_sysroot: Elapsed time: 8.35 seconds 
 do_sizecheck: Elapsed time: 0.03 seconds 
 do_strip: Elapsed time: 0.03 seconds 
 do_uboot_mkimage: Elapsed time: 0.04 seconds 
 do_unpack: Elapsed time: 42.50 seconds 
 do_validate_branches: Elapsed time: 11.14 seconds</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43936</commentid>
    <comment_count>4</comment_count>
      <attachid>2000</attachid>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 13:39:00 +0000</bug_when>
    <thetext>Created attachment 2000
Hacky patch tested for performance</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43937</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 13:42:24 +0000</bug_when>
    <thetext>As you can see, if we skip installing the source in the install step we take the build time from 9 minutes to 5 minutes. do_package 152s -&gt; 34s however there is much less time spent handling *huge* sstate tarballs which accounts for a lot of the time too. I&apos;m slightly surprised that doesn&apos;t show up on these timings from buildstats, need to check into why as do_poulate_sysroot should be miles faster (its probably due to it being a postfunc).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43938</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2014-06-13 13:44:10 +0000</bug_when>
    <thetext>Obviously this source is needed for some things and this patch as is would break perf. We should do something like the shared workdir we use for gcc but for the kernel (machine specific) which would unbreak kernel module and things like perf. Alternatively, we could just checkout the sources we need in those tasks.

I also have to wonder why do_unpack is so slow and whether we&apos;re at the point we can relax/remove some of the checks from things like validate_branches.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43939</commentid>
    <comment_count>7</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2014-06-13 13:53:27 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Obviously this source is needed for some things and this patch as is would
&gt; break perf. We should do something like the shared workdir we use for gcc
&gt; but for the kernel (machine specific) which would unbreak kernel module and
&gt; things like perf. Alternatively, we could just checkout the sources we need
&gt; in those tasks.
&gt; 
&gt; I also have to wonder why do_unpack is so slow and whether we&apos;re at the
&gt; point we can relax/remove some of the checks from things like
&gt; validate_branches.

On the validate_branches step .. yes, it will be relaxed shortly. I have a series prepped, but
it broke a couple of use cases that I&apos;m sorting out. So I&apos;ll be able to save some time there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43953</commentid>
    <comment_count>8</comment_count>
    <who name="Darren Hart">dvhart</who>
    <bug_when>2014-06-13 22:07:51 +0000</bug_when>
    <thetext>I swear do_package takes longer than 3 minutes for me. RP, can you describe your specific config/command for generating the data in Comment 3? I&apos;d like to reproduce in a typical build for my usecases and compare.

The shared workdir sounds like a good idea given the duration of do_unpack currently - that&apos;s a big tree.

I do like the idea of the external module support being a separate recipe rather than a config option for the main recipe. This make it easier to build later and include in a package feed without changing the DISTRO configuration or the RECIPE configuration in local-only hacks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47094</commentid>
    <comment_count>9</comment_count>
    <who name="Alexandru Georgescu">alexandru.c.georgescu</who>
    <bug_when>2014-11-20 09:16:16 +0000</bug_when>
    <thetext>To be discussed internally with Lucian and Costin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50666</commentid>
    <comment_count>10</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-04-30 15:25:29 +0000</bug_when>
    <thetext>We did end up doing this in the 1.8 cycle and changed things so that on target kernel module builds are handled by a separate recipe now. We also moved the kernel to using a shared directory for the build process which simplified the amount of copying going on in the kernel tasks. Since we implemented the performance ideas I&apos;m aware of, I believe this is resolved now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50667</commentid>
    <comment_count>11</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-04-30 15:27:46 +0000</bug_when>
    <thetext>Darren, the data in Comment 3 was something like &quot;bitbake virtual/kernel; bitbake virtual/kernel -c clean; time bitbake virtual/kernel&quot; and then looking at the files in tmp/buildstats/&lt;build&gt;/linux-yocto/* and taking the Eslapsed time entries from those files.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>2000</attachid>
            <date>2014-06-13 13:39:00 +0000</date>
            <delta_ts>2014-06-13 13:39:00 +0000</delta_ts>
            <desc>Hacky patch tested for performance</desc>
            <filename>kernel.patch</filename>
            <type>text/plain</type>
            <size>3503</size>
            <attacher name="Richard Purdie">richard.purdie</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL21ldGEvY2xhc3Nlcy9rZXJuZWwuYmJjbGFzcyBiL21ldGEvY2xhc3Nlcy9r
ZXJuZWwuYmJjbGFzcwppbmRleCA2ZWQxY2I3Li44YTRmY2MxIDEwMDY0NAotLS0gYS9tZXRhL2Ns
YXNzZXMva2VybmVsLmJiY2xhc3MKKysrIGIvbWV0YS9jbGFzc2VzL2tlcm5lbC5iYmNsYXNzCkBA
IC0yMjYsMjAgKzIyNiw3IEBAIGtlcm5lbF9kb19pbnN0YWxsKCkgewogCiAJZWNobyAiJHtLRVJO
RUxfSU1BR0VfQkFTRV9OQU1FfSIgPiRrZXJuZWxkaXIva2VybmVsLWltYWdlLW5hbWUKIAotCSMK
LQkjIENvcHkgdGhlIGVudGlyZSBzb3VyY2UgdHJlZS4gSW4gY2FzZSBhbiBleHRlcm5hbCBidWls
ZCBkaXJlY3RvcnkgaXMKLQkjIHVzZWQsIGNvcHkgdGhlIGJ1aWxkIGRpcmVjdG9yeSBvdmVyIGZp
cnN0LCB0aGVuIGNvcHkgb3ZlciB0aGUgc291cmNlCi0JIyBkaXIuIFRoaXMgZW5zdXJlcyB0aGUg
b3JpZ2luYWwgTWFrZWZpbGVzIGFyZSB1c2VkIG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