Disk logging as a hidden latency source
Posted: Sat Oct 31, 2026 2:26 pm
Writing log files seems harmless. In a tight loop, however, synchronous disk writes can stall a program for milliseconds, especially on slow or busy storage. An EA that logs on every tick can introduce significant delay.
The effect increases when the disk is shared or when antivirus software scans each write. On a VPS with network-attached storage, writes may take longer than expected.
The pattern shows up as irregular delays in tick processing. The EA seems fine in quiet markets and falls behind when ticks arrive quickly, which is exactly the time it matters.
Mitigation involves reducing log volume, buffering messages in memory and flushing periodically, and writing to a fast local drive. Use log levels so that detailed logging is enabled only when needed.
In MQL, file operations are blocking. Consider batching writes in the timer event rather than on every tick.
Measure by timing the logging calls. If they take more than a fraction of a millisecond, they are worth optimizing.
How much time does logging consume per tick in the current EA?
The effect increases when the disk is shared or when antivirus software scans each write. On a VPS with network-attached storage, writes may take longer than expected.
The pattern shows up as irregular delays in tick processing. The EA seems fine in quiet markets and falls behind when ticks arrive quickly, which is exactly the time it matters.
Mitigation involves reducing log volume, buffering messages in memory and flushing periodically, and writing to a fast local drive. Use log levels so that detailed logging is enabled only when needed.
In MQL, file operations are blocking. Consider batching writes in the timer event rather than on every tick.
Measure by timing the logging calls. If they take more than a fraction of a millisecond, they are worth optimizing.
How much time does logging consume per tick in the current EA?