Skip to content

Commit

Permalink
Prealocation before id table is filled
Browse files Browse the repository at this point in the history
  • Loading branch information
spirali authored and Kobzol committed Aug 23, 2024
1 parent d7d37f8 commit c35f7a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/hyperqueue/src/server/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 <TaskId as ItemId>::IdType),
Expand All @@ -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 <TaskId as ItemId>::IdType),
Expand Down

0 comments on commit c35f7a9

Please sign in to comment.