diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2018-04-18 17:24:29 +0800 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-04-24 10:13:39 +1200 |
commit | 430ca8c639e96f2490dafae83db85c63d0264500 (patch) | |
tree | 596e69b2984328203ea249117830d0921df4ab26 /layerindex/update_layer.py | |
parent | 51047ec58cd4d6a315ecf11f4defd69bd08e779e (diff) | |
download | openembedded-core-contrib-430ca8c639e96f2490dafae83db85c63d0264500.tar.gz |
update_layer.py: move layer validation to update.py (Performance improve)
The utils.setup_django() costs a lot of time, but both update.py and
update_layer.py call it, so move layer validation from update_layer.py
to update.py to avoid calling update_layer.py when possible can save a
lot of time.
Now we don't have to call update_layer.py in the following cases:
* The branch doesn't exist
* The layer is already update to date on specified branch (when no
reload)
* The layer dir or conf/layer.layer doesn't exist
We can save up to 98% time in my testing:
$ update.py -b master --nofetch [--fullreload]
Before Now Reduced
No update: 276s 3.6s 98%
Partial update: 312s 87s 72%
Full reload: 1016s 980s 3%
Note:
* All of the testing are based on --nofetch
* "No update" means all layers on the branch is up-to-date, for
example, when we run it twice, there is no update in the second run,
so we only need about 3s now, which is the most common case when we
use cron to run it per half an hour.
* "Partial update" means part of the layers have been updated.
* "Full reload" means all of the layers have been updated.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/update_layer.py')
-rw-r--r-- | layerindex/update_layer.py | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 60a1f2e528..69ca3c64ce 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -287,19 +287,10 @@ def main(): # Collect repo info repo = git.Repo(repodir) assert repo.bare == False - try: - if options.nocheckout: - topcommit = repo.commit('HEAD') - else: - topcommit = repo.commit('origin/%s' % branchname) - except: - if layerbranch: - logger.info("layer %s - branch %s no longer exists, removing it from database" % (layer.name, branchdesc)) - if not options.dryrun: - layerbranch.delete() - else: - logger.info("Skipping update of layer %s - branch %s doesn't exist" % (layer.name, branchdesc)) - sys.exit(1) + if options.nocheckout: + topcommit = repo.commit('HEAD') + else: + topcommit = repo.commit('origin/%s' % branchname) tinfoil = None tempdir = None @@ -329,17 +320,6 @@ def main(): # Find latest commit in subdirectory # A bit odd to do it this way but apparently there's no other way in the GitPython API topcommit = next(repo.iter_commits('origin/%s' % branchname, paths=layerbranch.vcs_subdir), None) - if not topcommit: - # This will error out if the directory is completely invalid or had never existed at this point - # If it previously existed but has since been deleted, you will get the revision where it was - # deleted - so we need to handle that case separately later - if newbranch: - logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir)) - elif layerbranch.vcs_subdir: - logger.error("Subdirectory for layer %s does not exist on branch %s - if this is legitimate, the layer branch record should be deleted" % (layer.name, branchdesc)) - else: - logger.error("Failed to get last revision for layer %s on branch %s" % (layer.name, branchdesc)) - sys.exit(1) layerdir = os.path.join(repodir, layerbranch.vcs_subdir) layerdir_start = os.path.normpath(layerdir) + os.sep @@ -354,17 +334,6 @@ def main(): if not options.nocheckout: utils.checkout_layer_branch(layerbranch, repodir, logger=logger) - if layerbranch.vcs_subdir and not os.path.exists(layerdir): - if newbranch: - logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir)) - else: - logger.error("Subdirectory for layer %s does not exist on branch %s - if this is legitimate, the layer branch record should be deleted" % (layer.name, branchdesc)) - sys.exit(1) - - if not os.path.exists(os.path.join(layerdir, 'conf/layer.conf')): - logger.error("conf/layer.conf not found for layer %s - is subdirectory set correctly?" % layer.name) - sys.exit(1) - logger.info("Collecting data for layer %s on branch %s" % (layer.name, branchdesc)) try: (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout, logger=logger) |