Adding and using convenience config_log(msg)
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
742e6692d5
commit
dd8c4311b7
|
@ -234,7 +234,7 @@ function config_cache_fetch(ConfigFetchParams $params) : ConfigFetchResult
|
||||||
$result = _config_cache_fetch($params);
|
$result = _config_cache_fetch($params);
|
||||||
|
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Fetch from cache: " . round(microtime(true) - $t,2) . " sec.\n";
|
config_log("Fetch from cache: " . round(microtime(true) - $t,2) . " sec.");
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ function _config_cache_fetch(ConfigFetchParams $params) : ConfigFetchResult
|
||||||
if(array_search(false, $results_by_job, true/*strict*/) !== false)
|
if(array_search(false, $results_by_job, true/*strict*/) !== false)
|
||||||
{
|
{
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Result error detected, trying serial processing...\n";
|
config_log("Result error detected, trying serial processing...");
|
||||||
$results_by_job = _config_worker_run_procs($params, $jobs, true);
|
$results_by_job = _config_worker_run_procs($params, $jobs, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,10 +269,10 @@ function _config_cache_fetch(ConfigFetchParams $params) : ConfigFetchResult
|
||||||
$t = microtime(true);
|
$t = microtime(true);
|
||||||
$result = _config_merge_fetch_results($params, $results_by_job);
|
$result = _config_merge_fetch_results($params, $results_by_job);
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Merge results: " . round(microtime(true) - $t,2) . " sec.\n";
|
config_log("Merge results: " . round(microtime(true) - $t,2) . " sec.");
|
||||||
|
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Miss(Fast)/Total: {$result->stales}($result->fast_jsons)/" . sizeof($result->all) . "\n";
|
config_log("Miss(Fast)/Total: {$result->stales}($result->fast_jsons)/" . sizeof($result->all));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,11 @@ class ConfigGlobals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function config_log($msg)
|
||||||
|
{
|
||||||
|
echo "[CFG] $msg\n";
|
||||||
|
}
|
||||||
|
|
||||||
function config_get_cache_path(ConfigGlobals $globals, string $file) : string
|
function config_get_cache_path(ConfigGlobals $globals, string $file) : string
|
||||||
{
|
{
|
||||||
return config_get_tmp_build_path($globals, $file . '.cacheb');
|
return config_get_tmp_build_path($globals, $file . '.cacheb');
|
||||||
|
@ -109,9 +114,9 @@ function config_bench_load(ConfigGlobals $globals, string $file)
|
||||||
$parse_res = config_parse($globals->base_dirs, $file);
|
$parse_res = config_parse($globals->base_dirs, $file);
|
||||||
if($parse_res->error !== 0)
|
if($parse_res->error !== 0)
|
||||||
throw new Exception("Error({$parse_res->error}) while loading JSON from {$file}:\n" . $parse_res->error_descr);
|
throw new Exception("Error({$parse_res->error}) while loading JSON from {$file}:\n" . $parse_res->error_descr);
|
||||||
echo "[CFG] Parse: " . (microtime(true) - $t) . "\n";
|
config_log("Parse: " . (microtime(true) - $t));
|
||||||
$t = microtime(true);
|
$t = microtime(true);
|
||||||
$config = config_load_from_kv_array($globals, $base_dir, $file, $parse_res->parsed_arr, $conf_id);
|
$config = config_load_from_kv_array($globals, $base_dir, $file, $parse_res->parsed_arr, $conf_id);
|
||||||
echo "[CFG] Load: " . (microtime(true) - $t) . "\n";
|
config_log("Load: " . (microtime(true) - $t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,11 @@ function config_pack_bundle(ConfigPackParams $params) : string
|
||||||
throw new Exception("Unknown binary format: {$params->binary_format}");
|
throw new Exception("Unknown binary format: {$params->binary_format}");
|
||||||
|
|
||||||
if($params->debug)
|
if($params->debug)
|
||||||
echo "[CFG] Packed entries: " . sizeof($params->cache_entries) . ", total: " .
|
config_log("Packed entries: " . sizeof($params->cache_entries) . ", total: " .
|
||||||
kb($packed_data) . ", format: {$params->binary_format}, lz4: " .
|
kb($packed_data) . ", format: {$params->binary_format}, lz4: " .
|
||||||
var_export($params->use_lz4, true) . ", refs: " . var_export($params->use_config_refs, true) .
|
var_export($params->use_lz4, true) . ", refs: " . var_export($params->use_config_refs, true) .
|
||||||
", CRC: " . crc32($packed_data) .
|
", CRC: " . crc32($packed_data) .
|
||||||
", " . round(microtime(true) - $t,2) . " sec.\n";
|
", " . round(microtime(true) - $t,2) . " sec.");
|
||||||
|
|
||||||
return $packed_data;
|
return $packed_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ function config_scan_files(
|
||||||
}
|
}
|
||||||
|
|
||||||
if($verbose)
|
if($verbose)
|
||||||
echo "[CFG] File scan: {$result->count()}, done " . round(microtime(true) - $t,2) . " sec.\n";
|
config_log("File scan: {$result->count()}, done " . round(microtime(true) - $t,2) . " sec.");
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ function _config_worker_func(ConfigFetchParams $params, array $job) : array
|
||||||
|
|
||||||
list($idx, $start_time, $chunk) = $job;
|
list($idx, $start_time, $chunk) = $job;
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Worker $idx (" . sizeof($chunk) . ") started (".round(microtime(true)-$start_time, 2)." sec)\n";
|
config_log("Worker $idx (" . sizeof($chunk) . ") started (".round(microtime(true)-$start_time, 2)." sec)");
|
||||||
|
|
||||||
$fast_parser_num = 0;
|
$fast_parser_num = 0;
|
||||||
$results = array();
|
$results = array();
|
||||||
|
@ -65,7 +65,7 @@ function _config_worker_func(ConfigFetchParams $params, array $job) : array
|
||||||
list($base_dir, $file) = $chunk_data;
|
list($base_dir, $file) = $chunk_data;
|
||||||
|
|
||||||
if($params->verbose && $file_idx > 0 && ($file_idx % 500) == 0)
|
if($params->verbose && $file_idx > 0 && ($file_idx % 500) == 0)
|
||||||
echo "[CFG] Worker $idx progress: " . round($file_idx / sizeof($chunk) * 100) . "% ...\n";
|
config_log("Worker $idx progress: " . round($file_idx / sizeof($chunk) * 100) . "% ...");
|
||||||
|
|
||||||
$cache_file = config_get_cache_path($params->globals, $file);
|
$cache_file = config_get_cache_path($params->globals, $file);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ function _config_worker_func(ConfigFetchParams $params, array $job) : array
|
||||||
}
|
}
|
||||||
|
|
||||||
if($params->verbose)
|
if($params->verbose)
|
||||||
echo "[CFG] Worker $idx done (".round(microtime(true)-$start_time, 2)." sec)\n";
|
config_log("Worker $idx done (".round(microtime(true)-$start_time, 2)." sec)");
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue