Skip to contentSkip to conversation

Prevent loading unnecessary resources from layerindex-web

layerindexlib Piotr Buliński 2 participants 3 messages Mar 30

lore
Share & tools
lore
#0 lore raw

When I was using bitbake-layers layerindex-fetch ... I noticed it being quite slow. Upon further investigation, I found that the call to load_layerindex() inside layerindexlib was called with the deafult load argument.

The deafault was set to ['layerDependencies', 'recipes', 'machines', 'distros'] where the layerindex-fetch effectively requires only ['layerDependencies'].

So whenever a layerindex-fetch is used, we pull for example 'recipes', which is about 18-20MB in size - it takes time to produce that response by the layerindex-web and ship over the internet, just to be discarded.

This change addresses the issue by setting a "sane" default (empty load list) and sets a correct, explicit load list whenever it's needed (e.g. toaster) by the caller.

Lastly, there seems to be an error when the cooker index is loaded in the process with the load='layerDependencies', that's incorrect, as the implementation expects also a list, so that's corrected as well.

---
 lib/bblayers/layerindex.py                       | 4 ++--
 lib/layerindexlib/__init__.py                    | 6 +++---
 lib/toaster/orm/management/commands/lsupdates.py | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)
lib/bblayers/layerindex.py +2 -2
index 308a5532d..2ba1103a3 100644
@@ -116,7 +116,7 @@ class LayerIndexPlugin(ActionPlugin):
 
         # Load the cooker DB
         cookerIndex = layerindexlib.LayerIndex(self.tinfoil.config_data)
-        cookerIndex.load_layerindex('cooker://', load='layerDependencies')
+        cookerIndex.load_layerindex('cooker://', load=['layerDependencies'])
 
         # Fast path, check if we already have what has been requested!
         (dependencies, invalidnames) = cookerIndex.find_dependencies(names=args.layername, ignores=ignore_layers)
@@ -137,7 +137,7 @@ class LayerIndexPlugin(ActionPlugin):
 
             for remoteurl in _construct_url(apiurl, branches):
                 logger.plain("Loading %s..." % remoteurl)
-                remoteIndex.load_layerindex(remoteurl)
+                remoteIndex.load_layerindex(remoteurl, load=['layerDependencies'])
 
             if remoteIndex.is_empty():
                 logger.error("Remote layer index %s is empty for branches %s" % (apiurl, branches))
lib/layerindexlib/__init__.py +3 -3
index c3265ddaa..e693e5c11 100644
@@ -174,15 +174,15 @@ class LayerIndex():
         return res
 
 
-    def load_layerindex(self, indexURI, load=['layerDependencies', 'recipes', 'machines', 'distros'], reload=False):
+    def load_layerindex(self, indexURI, load=[], reload=False):
         '''Load the layerindex.
 
            indexURI - An index to load.  (Use multiple calls to load multiple indexes)
 
            reload - If reload is True, then any previously loaded indexes will be forgotten.
 
-           load - List of elements to load.  Default loads all items.
-                  Note: plugs may ignore this.
+           load - List of elements to load. By default, an empty list is used to keep things lean.
+                  Callers need to specify a minimal set of elements to load, such as ['layerDependencies'] for dependency resolution.
 
 The format of the indexURI:
 
lib/toaster/orm/management/commands/lsupdates.py +2 -1
index 0ee00aa15..153b26f60 100644
@@ -105,7 +105,8 @@ class Command(BaseCommand):
             url_branches = ";branch=%s" % ','.join(allowed_branch_names)
         else:
             url_branches = ""
-        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches))
+        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches),
+                                   load=['layerDependencies', 'recipes', 'machines', 'distros'])
 
         http_progress.stop()
 
#1 lore raw

I think probably you meant to send this to yocto-patches@ ML?

Quoted 96 lines · Piotr Buliński via lists.openembedded.org

When I was using bitbake-layers layerindex-fetch ... I noticed it being quite slow. Upon further investigation, I found that the call to load_layerindex() inside layerindexlib was called with the deafult load argument.

The deafault was set to ['layerDependencies', 'recipes', 'machines', 'distros'] where the layerindex-fetch effectively requires only ['layerDependencies'].

So whenever a layerindex-fetch is used, we pull for example 'recipes', which is about 18-20MB in size - it takes time to produce that response by the layerindex-web and ship over the internet, just to be discarded.

This change addresses the issue by setting a "sane" default (empty load list) and sets a correct, explicit load list whenever it's needed (e.g. toaster) by the caller.

Lastly, there seems to be an error when the cooker index is loaded in the process with the load='layerDependencies', that's incorrect, as the implementation expects also a list, so that's corrected as well.

---
 lib/bblayers/layerindex.py                       | 4 ++--
 lib/layerindexlib/__init__.py                    | 6 +++---
 lib/toaster/orm/management/commands/lsupdates.py | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)
lib/bblayers/layerindex.py +2 -2
index 308a5532d..2ba1103a3 100644
@@ -116,7 +116,7 @@ class LayerIndexPlugin(ActionPlugin):
 
         # Load the cooker DB
         cookerIndex = layerindexlib.LayerIndex(self.tinfoil.config_data)
-        cookerIndex.load_layerindex('cooker://', load='layerDependencies')
+        cookerIndex.load_layerindex('cooker://', load=['layerDependencies'])
 
         # Fast path, check if we already have what has been requested!
         (dependencies, invalidnames) = cookerIndex.find_dependencies(names=args.layername, ignores=ignore_layers)
@@ -137,7 +137,7 @@ class LayerIndexPlugin(ActionPlugin):
 
             for remoteurl in _construct_url(apiurl, branches):
                 logger.plain("Loading %s..." % remoteurl)
-                remoteIndex.load_layerindex(remoteurl)
+                remoteIndex.load_layerindex(remoteurl, load=['layerDependencies'])
 
             if remoteIndex.is_empty():
                 logger.error("Remote layer index %s is empty for branches %s" % (apiurl, branches))
lib/layerindexlib/__init__.py +3 -3
index c3265ddaa..e693e5c11 100644
@@ -174,15 +174,15 @@ class LayerIndex():
         return res
 
 
-    def load_layerindex(self, indexURI, load=['layerDependencies', 'recipes', 'machines', 'distros'], reload=False):
+    def load_layerindex(self, indexURI, load=[], reload=False):
         '''Load the layerindex.
 
            indexURI - An index to load.  (Use multiple calls to load multiple indexes)
 
            reload - If reload is True, then any previously loaded indexes will be forgotten.
 
-           load - List of elements to load.  Default loads all items.
-                  Note: plugs may ignore this.
+           load - List of elements to load. By default, an empty list is used to keep things lean.
+                  Callers need to specify a minimal set of elements to load, such as ['layerDependencies'] for dependency resolution.
 
 The format of the indexURI:
 
lib/toaster/orm/management/commands/lsupdates.py +2 -2
index 0ee00aa15..153b26f60 100644
@@ -105,7 +105,8 @@ class Command(BaseCommand):
             url_branches = ";branch=%s" % ','.join(allowed_branch_names)
         else:
             url_branches = ""
-        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches))
+        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches),
+                                   load=['layerDependencies', 'recipes', 'machines', 'distros'])
 
         http_progress.stop()
 
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#125866): https://lists.openembedded.org/g/openembedded-devel/message/125866
Mute This Topic: https://lists.openembedded.org/mt/118578936/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Sorry, that was supposed to go to [email protected]

Quoted 116 lines · Gyorgy Sarvari

I think probably you meant to send this to yocto-patches@ ML?

Quoted 1 line · Piotr Buliński via lists.openembedded.org

When I was using bitbake-layers layerindex-fetch ... I noticed it

being quite

Quoted 1 line

slow. Upon further investigation, I found that the call to

load_layerindex()

Quoted 3 lines

inside layerindexlib was called with the deafult load argument.

The deafault was set to ['layerDependencies', 'recipes', 'machines',

'distros']

Quoted 1 line

where the layerindex-fetch effectively requires only

['layerDependencies'].

Quoted 2 lines

So whenever a layerindex-fetch is used, we pull for example 'recipes',

which

Quoted 4 lines

is about 18-20MB in size - it takes time to produce that response by the layerindex-web and ship over the internet, just to be discarded.

This change addresses the issue by setting a "sane" default (empty

load list)

Quoted 1 line

and sets a correct, explicit load list whenever it's needed (e.g.

toaster)

Quoted 18 lines

by the caller.

Lastly, there seems to be an error when the cooker index is loaded in the process with the load='layerDependencies', that's incorrect, as the implementation expects also a list, so that's corrected as well.

---
 lib/bblayers/layerindex.py                       | 4 ++--
 lib/layerindexlib/__init__.py                    | 6 +++---
 lib/toaster/orm/management/commands/lsupdates.py | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)
lib/bblayers/layerindex.py +0 -0
index 308a5532d..2ba1103a3 100644

lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 119

Quoted 4 lines
lib/bblayers/layerindex.py +0 -1
@@ -116,7 +116,7 @@ class LayerIndexPlugin(ActionPlugin):
 
         # Load the cooker DB
         cookerIndex = layerindexlib.LayerIndex(self.tinfoil.config_data)
-        cookerIndex.load_layerindex('cooker://',

load='layerDependencies')

lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 119

Quoted 1 line
lib/bblayers/layerindex.py +1 -0
+        cookerIndex.load_layerindex('cooker://',

load=['layerDependencies'])

lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 121

Quoted 3 lines
lib/bblayers/layerindex.py +0 -0
         # Fast path, check if we already have what has been requested!
         (dependencies, invalidnames) =

cookerIndex.find_dependencies(names=args.layername, ignores=ignore_layers)

lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 140

Quoted 6 lines
lib/bblayers/layerindex.py +1 -1
@@ -137,7 +137,7 @@ class LayerIndexPlugin(ActionPlugin):
 
             for remoteurl in _construct_url(apiurl, branches):
                 logger.plain("Loading %s..." % remoteurl)
-                remoteIndex.load_layerindex(remoteurl)
+                remoteIndex.load_layerindex(remoteurl,

load=['layerDependencies'])

lib/bblayers/layerindex.py class LayerIndexPlugin(ActionPlugin): · line 142

Quoted 3 lines
lib/bblayers/layerindex.py +0 -0
             if remoteIndex.is_empty():
                 logger.error("Remote layer index %s is empty for

branches %s" % (apiurl, branches))

Review

Quoted 1 line
(quoted diff) +0 -0

b/lib/layerindexlib/__init__.py

lib/layerindexlib/__init__.py class LayerIndex(): · line 177

Quoted 8 lines

index c3265ddaa..e693e5c11 100644

lib/layerindexlib/__init__.py +0 -1
@@ -174,15 +174,15 @@ class LayerIndex():
         return res
 
 
-    def load_layerindex(self, indexURI, load=['layerDependencies',

'recipes', 'machines', 'distros'], reload=False):

lib/layerindexlib/__init__.py class LayerIndex():

Quoted 4 lines
lib/layerindexlib/__init__.py +1 -0
+    def load_layerindex(self, indexURI, load=[], reload=False):
         '''Load the layerindex.
 
            indexURI - An index to load.  (Use multiple calls to load

multiple indexes)

lib/layerindexlib/__init__.py class LayerIndex(): · line 181

Quoted 2 lines
lib/layerindexlib/__init__.py +0 -0
            reload - If reload is True, then any previously loaded

indexes will be forgotten.

lib/layerindexlib/__init__.py class LayerIndex():

Quoted 4 lines
lib/layerindexlib/__init__.py +1 -2
-           load - List of elements to load.  Default loads all items.
-                  Note: plugs may ignore this.
+           load - List of elements to load. By default, an empty list

is used to keep things lean.

lib/layerindexlib/__init__.py class LayerIndex(): · line 183

Quoted 1 line
lib/layerindexlib/__init__.py +1 -0
+                  Callers need to specify a minimal set of elements to

load, such as ['layerDependencies'] for dependency resolution.

Review

Quoted 4 lines
lib/layerindexlib/__init__.py +0 -0
 The format of the indexURI:
 
(quoted diff) +0 -0

b/lib/toaster/orm/management/commands/lsupdates.py

lib/toaster/orm/management/commands/lsupdates.py class Command(BaseCommand): · line 109

Quoted 10 lines

index 0ee00aa15..153b26f60 100644

lib/toaster/orm/management/commands/lsupdates.py +2 -1
@@ -105,7 +105,8 @@ class Command(BaseCommand):
             url_branches = ";branch=%s" % ','.join(allowed_branch_names)
         else:
             url_branches = ""
-        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches))
+        layerindex.load_layerindex("%s%s" % (self.apiurl, url_branches),
+                                   load=['layerDependencies',

'recipes', 'machines', 'distros'])

Quoted 8 lines
lib/toaster/orm/management/commands/lsupdates.py +0 -0
         http_progress.stop()