Skip to content

Rethink workcell task queues for higher efficiency #102

@luca-della-vedova

Description

@luca-della-vedova

From what I understand, in the the current architecture workcells have a queue of tasks that they need to execute. These tasks can only be performed in the order they are received because of the FIFO structure used.
Furthermore, tasks are enqueued when the work order is created, not when the task actually needs to be executed.
I would argue this is not a great design and is suboptimal in many ways, let's look at two different scenarios:

Long + short work order

Let's say we have, in order of submission:

  • A work order with 10 steps, with the last step being performed by workcell_1, submitted first and enqueued in the workcell as a first task.
  • A new incoming work order with workcell_1 performing the very first step.

Delayed work order

On the opposite end, let's say we have, in order of submission:

  • A two step work order, workcell_0 and workcell_1. Highly delayed because of an issue with workcell_0.
  • A work order with 10 steps, with the last performed by workcell_1, that goes smoothly and reaches workcell_1 task while the first work order is still delayed.

With the current architecture, in both scenarios workcell_1 will not be able to perform the task in the second work order until the first one is finished, which is not optimal.

I believe there are two possible ways to change the current architecture that are technically possible but since I didn't design it in the first place I'm not sure they have any tradeoff I'm not aware of:

  • Remove the task queueing that is done at the workcell level at work order creation and only queue a task when WorkcellRequest is called. I believe this has a potential drawback that we can't tell, at the workcell_orchestrator level, if the workcell will be used by any existing work orders or not so it's perhaps not the best solution.
  • Change the workcell storage to a different data structure. I would propose a priority heap where we order the workcell tasks with a custom function of whether the task is executable, submission time, optionally priority, such as:
    • If an executable task is compared to a non executable task, the executable task will be placed on top of the heap.
    • If two executable tasks are compared, the one with the highest priority will be executed first (future development, we have no concept of priority yet).
    • If two same priority tasks are compared, the one with the earliest submission timestamp will be executed first.

We then just iterate through the heap here, and as soon as a non executable task is found stop iterating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions