nextflow-io/nextflow

Adding a parameter for AnsiLogObserver delay

Open

#6518 aperta il 28 ott 2025

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Groovy (784 fork)batch import
good first issue

Metriche repository

Star
 (3382 star)
Metriche merge PR
 (Merge medio 3g 18h) (38 PR mergiate in 30 g)

Descrizione

New feature

In AnsiLogObserver, we have the following render function:

protected void render0(dummy) {
        while(!stopped) {
            if( hasProgressChanges() )
                renderProgress(statsObserver.quickStats)
            synchronized (this) {
                wait(200)
            }
        }
        //
        final stats = statsObserver.getStats()
        renderProgress(stats)
        renderSummary(stats)
    }

However, for long pipelines with multiple jobs, having a 200 milliseconds delay is not always practical and simply increases the log file size.

Use case

Having a configurable delay could be useful to reduce and simplify the log file. For a pipeline where jobs / tasks last tens of seconds or even minutes, polling every 1-5 seconds would be better than every 1/5 second. Memory usage gain will be however negligible.

Suggested implementation

This delay could either be set in an environment variable, or be picked up through a config file :

String intervalStr = System.getenv("NXF_ANSILOG_WAIT_INTERVAL_MS") ?: "200" 
long waitInterval = 200
try {
    waitInterval = intervalStr.toLong()
} catch (NumberFormatException e) {
    log.warn "Invalid value for NXF_ANSILOG_WAIT_INTERVAL_MS: $intervalStr. Using default 200ms."
}

Guida contributor