#1188 init: Create comps repos in parallel
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/pungi parallel-comps-kobo  into  master

file modified
+28 -7
@@ -19,6 +19,7 @@ 

  import shutil

  

  from kobo.shortcuts import run

+ from kobo.threads import run_in_threads

  

  from pungi.phases.base import PhaseBase

  from pungi.phases.gather import write_prepopulate_file
@@ -42,15 +43,23 @@ 

              # write global comps and arch comps, create comps repos

              global_comps = write_global_comps(self.compose)

              validate_comps(global_comps)

-             for arch in self.compose.get_arches():

-                 write_arch_comps(self.compose, arch)

-                 create_comps_repo(self.compose, arch, None)

+             num_workers = self.compose.conf['createrepo_num_threads']

+             run_in_threads(

+                 _arch_worker,

+                 [(self.compose, arch) for arch in self.compose.get_arches()],

+                 threads=num_workers,

+             )

  

              # write variant comps

-             for variant in self.compose.get_variants():

-                 for arch in variant.arches:

-                     write_variant_comps(self.compose, arch, variant)

-                     create_comps_repo(self.compose, arch, variant)

+             run_in_threads(

+                 _variant_worker,

+                 [

+                     (self.compose, arch, variant)

+                     for variant in self.compose.get_variants()

+                     for arch in variant.arches

+                 ],

+                 threads=num_workers,

+             )

  

          # download variants.xml / product.xml?

  
@@ -65,6 +74,18 @@ 

          write_prepopulate_file(self.compose)

  

  

+ def _arch_worker(_, args, num):

+     compose, arch = args

+     write_arch_comps(compose, arch)

+     create_comps_repo(compose, arch, None)

+ 

+ 

+ def _variant_worker(_, args, num):

+     compose, arch, variant = args

+     write_variant_comps(compose, arch, variant)

+     create_comps_repo(compose, arch, variant)

+ 

+ 

  def write_global_comps(compose):

      comps_file_global = compose.paths.work.comps(arch="global")

      msg = "Writing global comps file: %s" % comps_file_global

This should be mostly IO intensive operation, so running multiple commands at the same time should save us a tiny bit of time.

On a small dummy compose it's not really visible, but testing with real distribution comps file it shortens the init phase by about 15 % (which is really still seconds…).

Fixes: https://pagure.io/pungi/issue/981

rebased onto b1f1e4db705a946fed6ed762237221c1015950c5

4 years ago

I think underline (or double underline) is much more common in pungi code than "unused" and is (in my point of view) more obvious.

No other comments. The upper one is not much important for me.

rebased onto 9da70ee

4 years ago

Pull-Request has been merged by lsedlar

4 years ago