Skip to contentSkip to conversation

scripts/autobuild-run: make hung build timeout configurable

PATCH In review James Hilliard 2 participants 4 messages Jul 18, 2022 – Jul 14, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scripts/autobuild-run: make hung build timeout configurable

A reasonable value for this may vary depending on system load, specs and how many parallel builds are being run, so we should make it configurable.

Tweak LoadConfigFile parser to properly convert arg types.

---
Changes v1 -> v2:
- fix LoadConfigFile type conversion

---
 scripts/autobuild-run | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
scripts/autobuild-run +14 -12
index 337644f..e8530f9 100755
@@ -120,9 +120,6 @@ else:
     decode_bytes = _identity
     encode_str = _identity
 
-# A number of packages can take > 60mins of build time (e.g
-# gst-ffmpeg, qt5webkit, mimic)
-HUNG_BUILD_TIMEOUT = 120 # mins
 VERSION = 1
 
 def rm_ro(f, p, _):
@@ -208,7 +205,7 @@ class Builder:
     def __init__(self, instance, njobs, sysinfo,
                  http_url, http_login, http_password,
                  submitter, make_opts, nice, toolchains_csv,
-                 repo, upload, buildpid, debug):
+                 repo, upload, buildpid, debug, hung_build_timeout):
         self.instance = instance
         self.njobs = njobs
         self.sysinfo = sysinfo
@@ -223,6 +220,7 @@ class Builder:
         self.upload = upload
         self.buildpid = buildpid
         self.debug = debug
+        self.hung_build_timeout = hung_build_timeout
         self.build_parallel = False
 
         # frequently needed directories
@@ -388,7 +386,7 @@ class Builder:
             if os.path.exists(build_time_logfile):
                 mtime = datetime.datetime.fromtimestamp(os.stat(build_time_logfile).st_mtime)
 
-                if mtime < datetime.datetime.now() - datetime.timedelta(minutes=HUNG_BUILD_TIMEOUT):
+                if mtime < datetime.datetime.now() - datetime.timedelta(minutes=self.hung_build_timeout):
                     if sub_proc.poll() is None:
                         monitor_thread_hung_build_flag.set() # Used by do_build() to determine build hang
                         log_write(self.log, "INFO: build hung")
@@ -756,12 +754,10 @@ class LoadConfigFile(argparse.Action):
         config = configparser.RawConfigParser(allow_no_value=True)
         config.read_file(values)
         for k, v in config.items('main'):
-            key = k.replace("-", "_")
-            value = v
-            if key.startswith("no_") and value is None:
-                key = key[3:]
-                value = False
-            setattr(namespace, key, value)
+            args = ["--" + k]
+            if v:
+                args += [v]
+            parsed = parser.parse_args(args, namespace=namespace)
 
 def main():
 
@@ -811,6 +807,11 @@ def main():
     parser.add_argument("--debug", "-d",
                         help="Send log output to stdout instead of log file",
                         type=str)
+    parser.add_argument("--hung-build-timeout",
+                        help="A number of packages can take > 60mins of build "
+                             "time (e.g gst-ffmpeg, qt5webkit, mimic), sets "
+                             "timeout in minutes",
+                        type=int, default=120)
     toolchains_csv = parser.add_mutually_exclusive_group(required=False)
     toolchains_csv.add_argument("--toolchains-csv",
                                 dest="toolchains_csv",
@@ -895,7 +896,8 @@ def main():
             repo = args.repo,
             upload = upload,
             buildpid = buildpid,
-            debug = args.debug)
+            debug = args.debug,
+            hung_build_timeout = args.hung_build_timeout)
         p = multiprocessing.Process(target=builder.run_instance)
         p.start()
         processes.append(p)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 7 lines · On Sun, 17 Jul 2022 22:39:01 -0600 James Hilliard <[email protected]>…

A reasonable value for this may vary depending on system load, specs and how many parallel builds are being run, so we should make it configurable.

Tweak LoadConfigFile parser to properly convert arg types.

I am just wondering if it really makes sense to make this configurable. Indeed, it's very hard to figure out what is the "right" value.

Have you seen specific problems with the current timeout?

Thoas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
Quoted 8 lines · Thomas Petazzoni
Quoted 4 lines · On Sun, 17 Jul 2022 22:39:01 -0600 James Hilliard <[email protected]>…

A reasonable value for this may vary depending on system load, specs and how many parallel builds are being run, so we should make it configurable.

Quoted 8 lines
Quoted 3 lines

Tweak LoadConfigFile parser to properly convert arg types.

I am just wondering if it really makes sense to make this configurable. Indeed, it's very hard to figure out what is the "right" value.

Have you seen specific problems with the current timeout?

Yeah, I've had to raise it in some cases, mostly when running lots of single threaded builders on slower systems, there's a few packages like browsers that seem to often take a very long time to build and potentially run into timeout issues.

Quoted 6 lines

Thoas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to James Hilliard
Quoted 7 lines · James Hilliard

A reasonable value for this may vary depending on system load, specs and how many parallel builds are being run, so we should make it configurable.

Tweak LoadConfigFile parser to properly convert arg types.

I finally could convince Thomas :-)

Applied to buildroot-next master, thanks.

Regards,
Arnout

Quoted 77 lines

---
Changes v1 -> v2:
- fix LoadConfigFile type conversion

---
  scripts/autobuild-run | 26 ++++++++++++++------------
  1 file changed, 14 insertions(+), 12 deletions(-)
scripts/autobuild-run +12 -11
index 337644f..e8530f9 100755
@@ -120,9 +120,6 @@ else:
      decode_bytes = _identity
      encode_str = _identity
 
-# A number of packages can take > 60mins of build time (e.g
-# gst-ffmpeg, qt5webkit, mimic)
-HUNG_BUILD_TIMEOUT = 120 # mins
  VERSION = 1
 
  def rm_ro(f, p, _):
@@ -208,7 +205,7 @@ class Builder:
      def __init__(self, instance, njobs, sysinfo,
                   http_url, http_login, http_password,
                   submitter, make_opts, nice, toolchains_csv,
-                 repo, upload, buildpid, debug):
+                 repo, upload, buildpid, debug, hung_build_timeout):
          self.instance = instance
          self.njobs = njobs
          self.sysinfo = sysinfo
@@ -223,6 +220,7 @@ class Builder:
          self.upload = upload
          self.buildpid = buildpid
          self.debug = debug
+        self.hung_build_timeout = hung_build_timeout
          self.build_parallel = False
 
          # frequently needed directories
@@ -388,7 +386,7 @@ class Builder:
              if os.path.exists(build_time_logfile):
                  mtime = datetime.datetime.fromtimestamp(os.stat(build_time_logfile).st_mtime)
 
-                if mtime < datetime.datetime.now() - datetime.timedelta(minutes=HUNG_BUILD_TIMEOUT):
+                if mtime < datetime.datetime.now() - datetime.timedelta(minutes=self.hung_build_timeout):
                      if sub_proc.poll() is None:
                          monitor_thread_hung_build_flag.set() # Used by do_build() to determine build hang
                          log_write(self.log, "INFO: build hung")
@@ -756,12 +754,10 @@ class LoadConfigFile(argparse.Action):
          config = configparser.RawConfigParser(allow_no_value=True)
          config.read_file(values)
          for k, v in config.items('main'):
-            key = k.replace("-", "_")
-            value = v
-            if key.startswith("no_") and value is None:
-                key = key[3:]
-                value = False
-            setattr(namespace, key, value)
+            args = ["--" + k]
+            if v:
+                args += [v]
+            parsed = parser.parse_args(args, namespace=namespace)
 
  def main():
 
@@ -811,6 +807,11 @@ def main():
      parser.add_argument("--debug", "-d",
                          help="Send log output to stdout instead of log file",
                          type=str)
+    parser.add_argument("--hung-build-timeout",
+                        help="A number of packages can take > 60mins of build "
+                             "time (e.g gst-ffmpeg, qt5webkit, mimic), sets "
+                             "timeout in minutes",
+                        type=int, default=120)
      toolchains_csv = parser.add_mutually_exclusive_group(required=False)
      toolchains_csv.add_argument("--toolchains-csv",
                                  dest="toolchains_csv",

scripts/autobuild-run def main(): · line 903

Quoted 9 lines
scripts/autobuild-run +2 -1
@@ -895,7 +896,8 @@ def main():
              repo = args.repo,
              upload = upload,
              buildpid = buildpid,
-            debug = args.debug)
+            debug = args.debug,
+            hung_build_timeout = args.hung_build_timeout)
          p = multiprocessing.Process(target=builder.run_instance)
          p.start()
          processes.append(p)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot