Flip Performance Guide

Refining Arms

This chapter exposes a first easy and quite common optimisation.

Array and Map

Array has been built for concurrent modification with the lowest possible probability of conflicts. Internally it is a key/value container, where the key is an infinite precision floating point number that represents the location in the container. This number has a random behavior to handle concurrent insertion between the same elements.

In our case here, we see intuitively that we don't need those properties. The number of arms is deterministic, and the key does not need any randomness. Map is a key/value container, and we can see here that the key can simply be the robot arm number (or more generally an arm identifier).

The optimisation here comes from the fact that generating Array keys takes some time.


The refined model, Model2 is implemented as below :

class Model2 : public DataModel <Model2> {};
class TaskRobot2 : public Task
   Map <RobotArm>    arms;


The bar chart below shows the time it takes to fill a document with 16 factories and various nbr of jobs (and so robots) for a total of 2 millions commands :

The next chapter, Refining Jobs, exposes a more subtle optimisation related to model redundancy.