Performance optimization suggestions for phase space file routines

Dear FLUKA expert:

I hope this message finds you well. I would like to share two suggestions for performance optimization related to phase space file processing in FLUKA, which I believe could enhance the user experience.

Firstly, regarding the issue of memory usage efficiency. In the simulation, when we using a 3 GB phase space file and starting 5 parallel processing processes (spawn), it was observed that each process would independently load a complete copy of the phase space file in memory. This has led to an increase in memory consumption, totaling about 5×3 GB. Although there is still abundant for CPU resources, memory resources have become extremely tight as a result. Would it be possible for future optimizations to consider implementing a shared memory mechanism? This approach could allow multiple parallel processes to access the same phase space file without duplicating its presence in memory, thereby reducing total memory usage to that of a single file and effectively alleviating pressure on available resources.

Secondly, regarding the issue of time efficiency in calculating cycles. Observations have shown that after each calculation cycle, the program releases the currently loaded phase space file data. At the beginning of the next calculation cycle, it will re read the file. For large phase space files, this reading introduces significant time overhead. If the simulation involves a large number of cycles, the accumulated read time will be considerable. In light of this observation, might it be feasible in future optimizations to cache phase space file data in memory across multiple consecutive cycles? By retaining this data after initially reading it during the first cycle and only releasing it once all relevant calculations are completed, we could avoid unnecessary duplicate disk accesses and reduce wasted computing time.

Thank you very much for considering these suggestions; I sincerely hope they provide useful insights for future developments within FLUKA.

1 Like

Dear Yaoxuan,

Thanks a lot for your message and observations.

  • Spawns:
    Phase-space data faces (indeed) duplication in RAM, as it is loaded in memory by each (independent) process. Note that this is the case for all of initialization data (constants, cross-sections tables, etc).
    I am assuming here that you need phase space files of such a significant size for your studies, and that they are in binary format.
    While implementing shared memory for multi-processes simulations would be possible and address this issue, it would be a relatively significant effort, and at this stage better wait for the new generation of FLUKA and integrate it directly there if needed.

  • Cycles:
    Instead, it is not possible to have persistent memory (without I/O) among cycles, as these are actually consecutive and distinct executions of FLUKA program: memory is cleared at the end of each FLUKA cycle, since the program terminates. So you will have to face the reading of a file at the beginning of each cycle (obviously in binary format to be efficient).

    Best regards,
    Gabrielle

1 Like