Reduce time spent in deciding not to do output.

Issue #1302 closed
Peter Diener created an issue

I noticed, during some scaling tests, that for my code a significant amount of time was spent by CarpetIOASCII, even though I only had it activated and didn't actually request any output. The reason is that in order to figure out whether to do output or not, there is a loop over all grid variables and a routine (TimeToOutput) is called. In this routine there is a check if the out_dir and out_vars parameters have been steered and if so update some internal data structures. It should be sufficient to do this before entering the loop over grid variables. The same issue is present in CarpetIOScalar and CarpetIOHDF5. The attached patches for CarpetIOASCII, CarpetIOScalar and CarpetIOHDF5 moves this check outside of the loop over grid variables and in addition bypasses the loop completely if the out_vars parameter string is the empty string. Note that the code where I noticed this problem uses large vectors of 1D grid arrays, and it turns out that Cactus counts each vector element as a distinct grid variables and the length of the loop over grid variables in my case was close to 100.000, which might explain why nobody has noticed this before.

Keyword: performance
Keyword: optimization

Comments (6)

  1. Erik Schnetter
    • changed status to open
    • removed comment

    This is okay to apply.

    Please update CarpetIOHDF5.patch, which currently introduces some commented-out code. It also seems the indentation of off near there.

  2. Frank Löffler
    • removed comment

    I think so - pending the changes Erik suggested. Also, now is probably the best time to do this.

  3. Log in to comment