From 6db1c9c1d8b5eeba9fd522386fa41ba70c31b57f Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 24 Jun 2024 16:17:46 -0500 Subject: [PATCH] more control of FS (#243) Co-authored-by: Thomas Applencourt --- .github/workflows/presubmit.yml | 1 + xprof/sync_daemon_fs | 2 +- xprof/xprof.rb.in | 30 +++++++++++++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index c0d8e3e7..ac58aa04 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -145,6 +145,7 @@ jobs: bats_file: ['mpi_sync_daemon', 'mpi_iprof'] include: - bats_file: 'iprof' + thapi_sync_daemon: 'fs' # Need to force, if not `THAPI_SYNC_DAEMON` will be set to empty list env: THAPI_TEST_BIN: clinfo THAPI_BIN_DIR: ./build/ici/bin diff --git a/xprof/sync_daemon_fs b/xprof/sync_daemon_fs index 2d3fe45e..affe14d3 100755 --- a/xprof/sync_daemon_fs +++ b/xprof/sync_daemon_fs @@ -11,7 +11,7 @@ require 'etc' FOLDER_JOBID = File.join('.thapi_lock', mpi_job_id) SHARED_LOCAL_FILESYSTEM = File.join('/', 'dev', 'shm', Etc.getlogin, FOLDER_JOBID) -SHARED_GLOBAL_FILESYSTEM = File.join(env_fetch_first('HOME'), FOLDER_JOBID) +SHARED_GLOBAL_FILESYSTEM = File.join(env_fetch_first('THAPI_SHARED_PATH', 'HOME'), FOLDER_JOBID) # Use a log distribution seem to be a good tradeoff # between being nice to the FileSystem (not to many call) diff --git a/xprof/xprof.rb.in b/xprof/xprof.rb.in index 31271ba3..0be9c2f9 100755 --- a/xprof/xprof.rb.in +++ b/xprof/xprof.rb.in @@ -30,9 +30,9 @@ require 'date' module LoggerRefinement refine(Logger) do def info_block(message, &block) - info(message + ': entry') if message + info("#{message}: entry") if message block.call - info(message + ': exit') if message + info("#{message}: exit") if message end end end @@ -259,14 +259,28 @@ class Sync_daemon end def initialize - daemon_type = env_fetch_first('THAPI_SYNC_DAEMON', default: 'mpi') - lazy_exec("Initialize Sync_daemon #{daemon_type}") do - daemon = if File.exist?("#{__dir__}/sync_daemon_mpi") && daemon_type == 'mpi' + daemon_type = env_fetch_first('THAPI_SYNC_DAEMON') + daemon = case daemon_type + when nil + # Default is MPI + if File.exist?("#{__dir__}/sync_daemon_mpi") "#{__dir__}/sync_daemon_mpi" else + LOGGER.warn("No #{__dir__}/sync_daemon_mpi binary. Fall back to #{__dir__}/syc_daemon_f'") "#{__dir__}/sync_daemon_fs" end - LOGGER.debug { "spawn(#{daemon} #{Process.pid})" } + when 'mpi' + raise("No #{__dir__}/sync_daemon_mpi binary") unless File.exist?("#{__dir__}/sync_daemon_mpi") + + "#{__dir__}/sync_daemon_mpi" + when 'fs' + "#{__dir__}/sync_daemon_fs" + else + raise("Error: THAPI_SYNC_DAEMON value (#{daemon_type}) if not supported. Allowed: [mpi,fs] ") + end + + LOGGER.debug { "spawn(#{daemon} #{Process.pid})" } + lazy_exec("Initialize Sync_daemon #{daemon_type}") do @pid = spawn("#{daemon} #{Process.pid}") end end @@ -293,8 +307,10 @@ class Sync_daemon # we always call clean-up the daemon def self.open yield f = new + rescue StandardError + raise ensure - f.finalize + f.finalize if f end end