Compare commits

...
1 Commits
Author SHA1 Message Date
shinyobjectz 3b5934aeae Farm: a job's files are listed 32 at a time, and a slow start says where it went
Each file's stat is a trip to the volume: one after another, 511 files took 9.7 s at each end of every job. A job that drew nothing took 46 s; it takes 16 s.
2026-12-01 22:21:53 -08:00
+24 -10
View File
@@ -204,16 +204,21 @@ def run(cmd, cwd=None, env=None, timeout=6 * 3600):
def snapshot(d):
out = {}
for base, _, files in os.walk(d):
for f in files:
p = os.path.join(base, f)
try:
s = os.stat(p)
except OSError: # a link that points nowhere here (a box's kits/ link to its cache): not a file of the job's
continue
out[os.path.relpath(p, d)] = f"{s.st_size}:{s.st_mtime_ns}"
return out
# each file's stat is a trip to the volume (about 19 ms): one after another, 511 files took 9.7 s at each end of
# every job, drawn or not (12-01). Asked 32 at once
from concurrent.futures import ThreadPoolExecutor
paths = [os.path.join(base, f) for base, _, files in os.walk(d) for f in files]
def one(p):
try:
s = os.stat(p)
except OSError: # a link that points nowhere here (a box's kits/ link to its cache): not a file of the job's
return None
return os.path.relpath(p, d), f"{s.st_size}:{s.st_mtime_ns}"
with ThreadPoolExecutor(32) as pool:
return dict(x for x in pool.map(one, paths) if x)
class Log:
@@ -417,7 +422,9 @@ def coordinate(id: str, args: list[str], opts: dict):
log = Log(id)
log(f"raea farm: raea {' '.join(args)}")
t_start = [time.time()]
vol.reload()
t_start.append(time.time())
work = f"{JOBS}/{id}/work"
try:
farm_media.fetch(work, f"{ROOT}/blobs", log)
@@ -429,8 +436,15 @@ def coordinate(id: str, args: list[str], opts: dict):
return
# the media just linked (or fetched) into the job, committed before any GPU container reloads to render it: without
# this a still on this container found the footage and every GPU run of a video didn't ("No such file", 11-25)
t_start.append(time.time())
vol.commit()
t_start.append(time.time())
before = snapshot(work)
t_start.append(time.time())
# where a job's start goes, said when it's slow, as its end is
if t_start[-1] - t_start[0] > 5:
d = [b - a for a, b in zip(t_start, t_start[1:])]
log(f"raea farm: the job's start took {sum(d):.0f} s: reloading {d[0]:.1f} s, its media {d[1]:.1f} s, saving {d[2]:.1f} s, listing its files {d[3]:.1f} s")
try:
# a video's frames' keys (farm_keys.py): its runs kept by them under the raea that drew them (a release's
# version and the build's own file, so a new engine starts a store of its own; kept=0 draws every frame), and