@@ -350,6 +350,11 @@ def _prepare_seed_source(workdir: Path, seed_src_dir: Path, sha: str) -> None:
350350 subprocess .run (["chmod" , "-R" , "a+rwX" , str (seed_src_dir )], check = False )
351351
352352
353+ def _create_seed_source_dir () -> Path :
354+ """Create a unique disposable source-clone directory."""
355+ return Path (tempfile .mkdtemp (prefix = "perf-seed-src-" ))
356+
357+
353358def _prepare_jit_cache (cache_dir : Path ) -> Path :
354359 """Create a writable JIT cache directory for one task/backend bucket."""
355360 for subdir in (cache_dir / "warp" , cache_dir / "nv" ):
@@ -359,7 +364,15 @@ def _prepare_jit_cache(cache_dir: Path) -> Path:
359364 return cache_dir
360365
361366
362- def _jit_cache_path (cache_root : Path , target_branch : str , commit : str , task_id : str , backend_key : str ) -> Path :
367+ def _prepare_kit_cache (cache_dir : Path ) -> Path :
368+ """Create a writable Kit cache directory for one task/backend bucket."""
369+ cache_dir .mkdir (parents = True , exist_ok = True )
370+ # Kit writes shader and generated-node caches from the in-container user.
371+ _run (["chmod" , "-R" , "0777" , str (cache_dir )], check = False )
372+ return cache_dir
373+
374+
375+ def _cache_bucket_path (cache_root : Path , target_branch : str , commit : str , task_id : str , backend_key : str ) -> Path :
363376 """Return the cache shared by repeated samples of one task/backend bucket."""
364377 return (
365378 cache_root
@@ -370,14 +383,14 @@ def _jit_cache_path(cache_root: Path, target_branch: str, commit: str, task_id:
370383 )
371384
372385
373- def _cleanup_jit_cache ( cache_dir : Path ) -> None :
374- """Remove the disposable JIT cache for one seeder invocation."""
375- if not cache_dir .exists ():
386+ def _cleanup_run_dir ( run_dir : Path ) -> None :
387+ """Remove a disposable directory for one seeder invocation."""
388+ if not run_dir .exists ():
376389 return
377- subprocess .run (["chmod" , "-R" , "a+rwX" , str (cache_dir )], check = False , capture_output = True , text = True )
378- shutil .rmtree (cache_dir , ignore_errors = True )
379- if cache_dir .exists ():
380- print (f"::warning::[seed] Could not fully remove JIT cache { cache_dir } " )
390+ subprocess .run (["chmod" , "-R" , "a+rwX" , str (run_dir )], check = False , capture_output = True , text = True )
391+ shutil .rmtree (run_dir , ignore_errors = True )
392+ if run_dir .exists ():
393+ print (f"::warning::[seed] Could not fully remove run directory { run_dir } " )
381394
382395
383396def _docker_run_benchmark (
@@ -395,9 +408,10 @@ def _docker_run_benchmark(
395408 seed_token = f"--seed { task .seed } " if task .seed is not None else ""
396409 inner = (
397410 "set -e\n "
398- # Warp creates nested cache directories at runtime. A permissive umask
399- # keeps them writable when successive containers use different host uids .
411+ # Warp and Kit create nested cache directories at runtime. A permissive
412+ # umask keeps them writable for successive containers.
400413 "umask 000\n "
414+ "mkdir -p /tmp/bench_out\n "
401415 "cd /workspace/isaaclab\n "
402416 "rm -f _isaac_sim\n "
403417 "ln -s /isaac-sim _isaac_sim\n "
@@ -414,7 +428,6 @@ def _docker_run_benchmark(
414428 cmd = [
415429 "docker" ,
416430 "run" ,
417- "--rm" ,
418431 "--name" ,
419432 container_name ,
420433 "--init" ,
@@ -449,8 +462,6 @@ def _docker_run_benchmark(
449462 "-e" ,
450463 "CUDA_CACHE_PATH=/tmp/jit-cache/nv" ,
451464 "-v" ,
452- f"{ artifact_dir } :/tmp/bench_out" ,
453- "-v" ,
454465 f"{ jit_cache } :/tmp/jit-cache" ,
455466 "-v" ,
456467 f"{ kit_cache } :/isaac-sim/kit/cache" ,
@@ -462,7 +473,20 @@ def _docker_run_benchmark(
462473 cmd += [image , "-c" , inner ]
463474
464475 result = subprocess .run (cmd , text = True )
465- return result .returncode
476+ permissions_returncode = 0
477+ try :
478+ copy_result = subprocess .run (
479+ ["docker" , "cp" , f"{ container_name } :/tmp/bench_out/." , str (artifact_dir )],
480+ text = True ,
481+ )
482+ if copy_result .returncode == 0 :
483+ permissions_returncode = subprocess .run (
484+ ["chmod" , "-R" , "a+rwX" , str (artifact_dir )],
485+ text = True ,
486+ ).returncode
487+ finally :
488+ subprocess .run (["docker" , "rm" , "-f" , container_name ], capture_output = True , text = True )
489+ return result .returncode or copy_result .returncode or permissions_returncode
466490
467491
468492def _build_bench_result (task : TaskConfig , artifact_dir : Path , exit_code : int , wall_time_s : int ) -> None :
@@ -621,16 +645,18 @@ def main() -> int:
621645 artifacts_root = (workdir / args .artifacts_root ).resolve ()
622646 artifacts_root .mkdir (parents = True , exist_ok = True )
623647
624- seed_src_dir = (
625- Path (args .seed_src_dir ).resolve () if args .seed_src_dir else Path (tempfile .gettempdir ()) / "perf-seed-src"
626- )
648+ if args .seed_src_dir :
649+ seed_src_dir = Path (args .seed_src_dir ).resolve ()
650+ else :
651+ seed_src_dir = _create_seed_source_dir ()
652+ atexit .register (_cleanup_run_dir , seed_src_dir )
627653 run_id = os .environ .get ("GITHUB_RUN_ID" , f"local-{ os .getpid ()} " )
628654 run_attempt = os .environ .get ("GITHUB_RUN_ATTEMPT" , "0" )
629- jit_cache_root = workdir / "jit-cache" / "seed" / f"run-{ run_id } -attempt-{ run_attempt } "
630- atexit . register ( _cleanup_jit_cache , jit_cache_root )
631- kit_cache = workdir / "kit-cache"
632- kit_cache . mkdir ( parents = True , exist_ok = True )
633- _run ([ "chmod" , "-R" , "0777" , str ( kit_cache )], check = False )
655+ cache_run = f"run-{ run_id } -attempt-{ run_attempt } "
656+ jit_cache_root = workdir / "jit-cache" / "seed" / cache_run
657+ kit_cache_root = workdir / "kit-cache" / "seed" / cache_run
658+ atexit . register ( _cleanup_run_dir , jit_cache_root )
659+ atexit . register ( _cleanup_run_dir , kit_cache_root )
634660
635661 plan = _build_seed_plan (args )
636662 plan = _filter_plan_by_ancestry (
@@ -675,7 +701,10 @@ def main() -> int:
675701 continue
676702 for task in tasks :
677703 task_jit_cache = _prepare_jit_cache (
678- _jit_cache_path (jit_cache_root , target_branch , commit , task .task_id , task .backend_key )
704+ _cache_bucket_path (jit_cache_root , target_branch , commit , task .task_id , task .backend_key )
705+ )
706+ task_kit_cache = _prepare_kit_cache (
707+ _cache_bucket_path (kit_cache_root , target_branch , commit , task .task_id , task .backend_key )
679708 )
680709 for sample_idx in range (args .samples_per_commit ):
681710 total += 1
@@ -699,7 +728,7 @@ def main() -> int:
699728 task = task ,
700729 artifact_dir = artifact_dir ,
701730 jit_cache = task_jit_cache ,
702- kit_cache = kit_cache ,
731+ kit_cache = task_kit_cache ,
703732 seed_src_dir = seed_src_dir if source_mount else None ,
704733 container_name = container ,
705734 )
0 commit comments