I'm trying to build an ML model using LTSpice simulation data. I'm running 64 concurrent simulations of LTSpice using Wine on a 64-core Centos linux machine to acquire ideally several million data points. A typical simulation takes about 2-4 seconds. However I'm finding that after a few hundred concurrent simulations, the server slows down significantly and simulation times increase to 120+ seconds.
I'm looking for some advice on how to improve performance and speed up the simulation times. From what I can tell, performance degrades after several hundred simulations of LTSpice. However, individual memory usage for each simulation is not massive, but perhaps in total it's hosing up the system. I ran top to see what the process memory usage is and I don't see CPU or memory usage too far out of whack. My thought is that perhaps Wine or LTSpice are leaking memory, but I can't pinpoint the issue.
Here is what I've tried so far:
- LTSpice simulations are run in batch mode, each simulation in a separate directory. I delete all intermediate files (both LTSpice and Wine) after completing each simulation. Here is the command I'm running:
WINEDLLOVERRIDES=winemenubuilder.exe=d WINEDEBUG=-all wine-preloader /usr/local/bin/wine ~/.wine/drive_c/Program\\ Files/LTC/LTspiceXVII/XVIIx64.exe -Run -b [ltspice_file.asc]
- I use a virtual frame buffer (XVFB) to output any display windows. This had some significant impact on performance.
export DISPLAY=:1
Xvfb :1 -noreset &
- I was using python initially, but found that performance was terrible, so I switched to C++ multi-threading, which improved performance significantly. I'm using OMP and dynamic scheduling to allocate simulations. Note that each loop is based on a fixed chunk size of 500 simulation configurations, running across 64 threads.
#pragma omp parallel for schedule(dynamic,1)
for ( int i = 0; i < (int)sim_config.size(); i++ )
{
#pragma omp critical
{
++pid;
}
// run the LTspice simulation using configuration settings
run_simulation(pid, sim_config[i]);
}
- Every 500 simulations, I kill the wineserver (and related windows exe files) and reset the Xvfb application to clear memory:
system("wineserver -k; pkill .+\\.exe; pkill Xvfb; Xvfb :1 -noreset &")
- I've also tried flushing the linux cache memory:
sync; echo 3 > sudo /proc/sys/vm/drop_caches && sudo swapoff -a && sudo swapon -a
- I tried running less threads and smaller chunk sizes, but that doesn't seem to improve performance.
I appreciate any feedback or thoughts on how / where I can reduce the memory leakage.
Thanks!