extra tracing for bulk tag edit

This commit is contained in:
Shish 2023-06-25 14:42:24 +00:00
parent c5e2353447
commit e66acefa53
2 changed files with 10 additions and 4 deletions

View file

@ -107,7 +107,7 @@ function shm_set_timeout(?int $timeout=null): void
set_time_limit(is_null($timeout) ? 0 : $timeout);
}
if(ini_get('max_execution_time')) {
if (ini_get('max_execution_time')) {
shm_set_timeout((int)ini_get('max_execution_time') - 3);
}
@ -139,8 +139,8 @@ function send_event(Event $event): Event
ksort($my_event_listeners);
foreach ($my_event_listeners as $listener) {
if($_shm_timeout && ftime() > $_shm_timeout) {
throw new TimeoutException();
if ($_shm_timeout && ftime() > $_shm_timeout) {
throw new TimeoutException("Timeout while sending $event_name");
}
if ($tracer_enabled) {
$_tracer->begin(get_class($listener));

View file

@ -292,7 +292,7 @@ class TagEdit extends Extension
private function mass_tag_edit(string $search, string $replace)
{
global $database;
global $database, $tracer_enabled, $_tracer;
$search_set = Tag::explode(strtolower($search), false);
$replace_set = Tag::explode(strtolower($replace), false);
@ -317,6 +317,9 @@ class TagEdit extends Extension
$last_id = -1;
while (true) {
if ($tracer_enabled) {
$_tracer->begin("Batch starting with $last_id");
}
// make sure we don't look at the same images twice.
// search returns high-ids first, so we want to look
// at images with lower IDs than the previous.
@ -353,6 +356,9 @@ class TagEdit extends Extension
$last_id = $image->id;
}
if ($tracer_enabled) {
$_tracer->end();
}
}
}