Skip to content

Adding a parameter for AnsiLogObserver delay #6518

@ghislaindemael

Description

@ghislaindemael

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."
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions