<?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>4372</bug_id>
          
          <creation_ts>2013-04-22 09:03:31 +0000</creation_ts>
          <short_desc>[Performance] make hardlinks for files in DEPLOY_DIR when possible</short_desc>
          <delta_ts>2013-06-21 12:49:42 +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>deployment</component>
          <version>1.5</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</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.5 M1</target_milestone>
          
          <blocked>4643</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Yang">liezhi.yang</reporter>
          <assigned_to name="Robert Yang">liezhi.yang</assigned_to>
          <cc>mark.hatle</cc>
    
    <cc>mihai.lindner</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>32434</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-04-22 09:03:31 +0000</bug_when>
    <thetext>The rpm file (suppose PACKAGE_CLASSES = &quot;package_rpm&quot;) in ${WORK_DIR}/deploy-rpms (AKA  PKGWRITEDIRRPM) is the same as the one in DEPLOY_DIR_RPM (e.g., tmp/deploy/rpm), if we make symlink from DEPLOY_DIR_RPM to ${WORK_DIR}/deploy-rpms for the rpm file, it would save a lot time and disk space, or can we have a configuration variable to control this ? We copy the files by default, but can use the symlink when the user requires.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32444</commentid>
    <comment_count>1</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-04-22 10:28:25 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; The rpm file (suppose PACKAGE_CLASSES = &quot;package_rpm&quot;) in
&gt; ${WORK_DIR}/deploy-rpms (AKA  PKGWRITEDIRRPM) is the same as the one in
&gt; DEPLOY_DIR_RPM (e.g., tmp/deploy/rpm), if we make symlink from
&gt; DEPLOY_DIR_RPM to ${WORK_DIR}/deploy-rpms for the rpm file, it would save a
&gt; lot time and disk space, or can we have a configuration variable to control
&gt; this ? We copy the files by default, but can use the symlink when the user
&gt; requires.

Or we can just move the rpm files from ${WORK_DIR}/deploy-rpms to tmp/deploy/rpm which would also save the build time and disk space.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32468</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-04-22 13:59:29 +0000</bug_when>
    <thetext>I thought we were already hardlinking these files. It appears we don&apos;t so I&apos;d accept a patch to hardlink them instead of copying.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32469</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2013-04-22 14:10:43 +0000</bug_when>
    <thetext>Just an implementation note.  Can deploy-dir be set to another disk?  If so, we need to make sure that if a hardlink can NOT be generated, a copy is still made.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32472</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-04-22 14:36:09 +0000</bug_when>
    <thetext>In theory it can, in practise I don&apos;t want to support it and I&apos;m not aware of anyone doing that despite various other hardlinks we use in the system.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32573</commentid>
    <comment_count>5</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-04-24 10:22:20 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; In theory it can, in practise I don&apos;t want to support it and I&apos;m not aware
&gt; of anyone doing that despite various other hardlinks we use in the system.

Hi Richard, I set the DEPLOY_DIR to another filesystem, it worked well, and the bitbake.conf said:
# Setting DEPLOY_DIR outside of TMPDIR is helpful, when you are using
# packaged staging and/or multimachine.
DEPLOY_DIR ?= &quot;${TMPDIR}/deploy&quot;
DEPLOY_DIR_TAR = &quot;${DEPLOY_DIR}/tar&quot;
DEPLOY_DIR_IPK = &quot;${DEPLOY_DIR}/ipk&quot;
DEPLOY_DIR_RPM = &quot;${DEPLOY_DIR}/rpm&quot;

So it seems that we&apos;d better copy when can&apos;t hardlink, I&apos;ve made a patch for it, and it is in testing now, I will send it to the oe-core mailing list later:

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 67ddc46..3565627 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -198,7 +198,14 @@ def sstate_install(ss, d):
     # Run the actual file install
     for state in ss[&apos;dirs&apos;]:
         if os.path.exists(state[1]):
-            oe.path.copytree(state[1], state[2])
+            tgt_devno = None
+            if os.path.exists(state[2]):
+                tgt_devno = os.stat(state[2])
+            if (os.stat(state[1]).st_dev == tgt_devno):
+                oe.path.copyhardlinktree(state[1], state[2])
+            else:
+                oe.path.copytree(state[1], state[2])
+

     for postinst in (d.getVar(&apos;SSTATEPOSTINSTFUNCS&apos;, True) or &apos;&apos;).split():
         bb.build.exec_func(postinst, d)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32597</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-04-24 16:25:25 +0000</bug_when>
    <thetext>btw, patch looks good but can you please put the:

if (os.stat(state[1]).st_dev == tgt_devno):

into the  oe.path.copyhardlinktree() function as it belongs there, not in this code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32884</commentid>
    <comment_count>7</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-05-04 07:34:16 +0000</bug_when>
    <thetext>Merged into master:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=c51e8b4532361b11fe73c28613653c0f5aaf566b

And great thanks for RP&apos;s fix:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=61823f61948df24c3329de2766c715e562711a94</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34047</commentid>
    <comment_count>8</comment_count>
    <who name="Mihai Lindner">mihai.lindner</who>
    <bug_when>2013-06-21 12:49:42 +0000</bug_when>
    <thetext>It works.

# ls -lai tmp/deploy/rpm/x86_64/at-3.1.13-r5.x86_64.rpm tmp/work/x86_64-poky-linux/at/3.1.13-r5/deploy-rpms/x86_64/at-3.1.13-r5.x86_64.rpm
51123552 -rw-r--r-- 2 mihai users 34989 Jun 20 19:26 tmp/deploy/rpm/x86_64/at-3.1.13-r5.x86_64.rpm
51123552 -rw-r--r-- 2 mihai users 34989 Jun 20 19:26 tmp/work/x86_64-poky-linux/at/3.1.13-r5/deploy-rpms/x86_64/at-3.1.13-r5.x86_64.rpm</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>