gama-platform / gama

Main repository for developing the 2024+ versions of GAMA
https://gama-platform.org
GNU General Public License v3.0
16 stars 5 forks source link

[batch] Duration of batch experiment increases greatly for the first few rounds when using multiple threads #290

Open lesquoyb opened 3 weeks ago

lesquoyb commented 3 weeks ago

Describe the bug I run the exact same experiment 100 times using batch experiments and a repeat value of 3 and here is the total duration of each experiment during that batch: image we can see that the two first rounds of 3 simulations were faster than the rest, and the second round way already slower than the first, this is a consistent result I have after running this kind of experiment many times. What is weird is that the exact same batch but with a value of 1 for the repeat facet yields execution times that varies only a little since the beginning: image Here it's the 10 first execution and the duration has variations of about 10/20% contrary to the more than 100% we can observe in the previous case

So I think there's something fishy here and there's probably a way we can improve greatly execution time in batch.

To Reproduce Steps to reproduce the behavior:

  1. Run an experiment in batch with a repeat value greater than 1
  2. make the simulation save their duration at the end of it
  3. Observe that the duration raises for the first few rounds then (probably depending on your simulation) it stabilizes
  4. change the repeat to 1 and observe that it doesn't increase anymore

Expected behavior Somewhat constant simulation duration

AlexisDrogoul commented 2 weeks ago

Would you have a test model (not MAELIA :)) to reproduce this behavior ?

lesquoyb commented 2 weeks ago

with the fix of #291 it seems less visible: image

The code is any batch with parallel > 1, so for example:


model batchtest

global {
    float start <- gama.machine_time;
    float seed <- 3.1415;
    init {
        gama.pref_csv_separator <- ";";
    }

    reflex d {
        int size <- 250;
        let m <- matrix_with({size,size}, rnd(0,255));
        m <- shuffle(m);
        loop i from:0 to:size-1 {
            loop j from:0 to:size-1 {
                m[i,j] <- rnd(255);
            }
        }
    }

    reflex s when:cycle=49{
        save [int(self), int(gama.machine_time-start)] to:"data.csv" rewrite:false;
    }

}

experiment b type:batch until:cycle>=100 repeat:50 parallel:3 keep_simulations:false{

}
AlexisDrogoul commented 1 week ago

I've run 1000 simulations of the test model and the pattern is not here anymore. Instead we have a quite remarkable stability (except one episode, where I manipulated the UI a little bit).

image

So I would be in favor of closing this issue.