From 67317feafb4c97845bdb9546c42dedc8e25f353c Mon Sep 17 00:00:00 2001 From: Ada Bohm Date: Mon, 19 Aug 2024 20:17:47 +0200 Subject: [PATCH] Prealocation before id table is filled --- crates/hyperqueue/src/server/state.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/hyperqueue/src/server/state.rs b/crates/hyperqueue/src/server/state.rs index c5774ca6a..dd4ddeef9 100644 --- a/crates/hyperqueue/src/server/state.rs +++ b/crates/hyperqueue/src/server/state.rs @@ -3,7 +3,6 @@ use std::collections::BTreeMap; use std::sync::Arc; use chrono::Utc; - use tako::gateway::{ CancelTasks, FromGatewayMessage, LostWorkerMessage, NewWorkerMessage, TaskFailedMessage, TaskState, TaskUpdate, ToGatewayMessage, @@ -125,6 +124,7 @@ impl State { let job = self.get_job_mut(job_id).unwrap(); match &submit_desc.task_desc { JobTaskDescription::Array { ids, .. } => { + job.tasks.reserve(ids.id_count() as usize); ids.iter().enumerate().for_each(|(i, task_id)| { job.tasks.insert( TakoTaskId::new(base + i as ::IdType), @@ -136,6 +136,7 @@ impl State { }) } JobTaskDescription::Graph { tasks } => { + job.tasks.reserve(tasks.len()); tasks.iter().enumerate().for_each(|(i, task)| { job.tasks.insert( TakoTaskId::new(base + i as ::IdType),