Multithreading

PAMGuard can operate in either a single thread mode, or a multi-thread mode.

In multi-thread mode, each process within each PAMGuard module operates in a different processing thread, which allows several processes to take place at once in a multiprocessor computer.

In single thread mode, actions take place one at a time as data propagates through PAMGuard.

The advantage of multi-thread operation is that the different tasks will spread between multiple processing cores on the computer, thereby gaining access to more processing power.

In single thread operation, only a single processing core will be used, so less processing power is available.

Multi-threading may introduce instability in some modules, where certain processes have to happen in a certain sequence. It can also mean that the last second or so of a file, when re-processing offline, may still be in a buffer when processing stops, so never get analysed. So although multi-threading is usually preferable, single thread operation is maintained as an option.

As an example, when using PAMGuard to decimate wav files using three modules: Sound acquisition to read the files, a Decimator to drop the frequency, and a Sound Recorder to make lower frequency wav files, it’s better to turn multi-threading off, which will ensure no samples are lost, and in any case there would be no advantages in having multiple threads since you’re only doing one thing.

Turning multi-threading on and off

Multi-threading can be turned on and off from the Detection>Multi-threading menu command.

Main Menu

You can also set the amount of “jitter” between threads. This is the maximum amount of data that can be queued between two threads. If the data queue exceeds this time, then the earlier thread will wait until the second thread has processed some of the data in the queue.

More jitter allows more flexibility between threads which can allow PAMGuard to use multiple processor cores more efficiently. However, increased jitter can cause a loss of synchronisation between the processing, graphics output and sound play back. Generally, the default setting of 1000ms is about right for most operations.

Garbage Collection

The Java language handles garbage collection (clean up of unused objects in memory) very efficiently. Sometimes though it’s helpful to give it a ‘nudge’ and tell it to clean up more often in which case the ‘Run additional garbage collection’ option can be used.

Previous: Project Information

Next: Data Storage