Thread-safety of ProgressMeter

Open
#9 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia

Research direction

Start by reproducing the two examples with Progress, next!, @parallel, @spawn, and fetch to observe where progress updates are delayed or lost. Read the ProgressMeter implementation around Progress and next! and determine the supported behavior for updates from worker processes; done means progress is displayed during the parallel computation rather than only when it returns.

Written by the indexing model from the issue text.

Description

Hi Tim! Me again =)

Is there something special I need to do to use ProgressMeter for parallel computations? I tried something like

function long_running_function()
    n = 100
    p = Progress(n, 1)
    @parallel for i in 1:n
        sleep(0.1)
        next!(p)
    end
end

addprocs(3)

@everywhere using ProgressMeter

long_running_function()

but the call just returned and nothing was printed. I guess it's because p is only defined locally, but I haven't done enough parallel programming in Julia to see intuitively how to make it work on all processes. Adding some @spawn and @fetch calls has some, but not all of the desired, effect - it does print the progress line, but only at the very end, at the same time as the REPL prints the return value.

function long_running_function2()
    n = 100
    p = @spawn Progress(n, 1)
    @parallel for i in 1:n
        sleep(0.1)
        next!(fetch(p))
    end
end
Dominant language
Julia
Stars
789
Forks
91
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from timholy/ProgressMeter.jl

All issues in timholy/ProgressMeter.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.