Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
keywords = ["markov chain monte carlo", "probabilistic programming"]
license = "MIT"
desc = "A lightweight interface for common MCMC methods."
version = "5.7.0"
version = "5.7.1"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down
8 changes: 5 additions & 3 deletions src/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ internally take for single-chain sampling.
"""
abstract type AbstractProgressKwarg end

DEFAULT_N_UPDATES = 200

"""
CreateNewProgressBar

Expand All @@ -27,7 +29,7 @@ end
function finish_progress!(p::CreateNewProgressBar)
ProgressLogging.@logprogress p.name "done" _id = p.uuid
end
get_n_updates(::CreateNewProgressBar) = 200
get_n_updates(::CreateNewProgressBar) = DEFAULT_N_UPDATES

"""
NoLogging
Expand All @@ -38,7 +40,7 @@ struct NoLogging <: AbstractProgressKwarg end
init_progress!(::NoLogging) = nothing
update_progress!(::NoLogging, ::Any) = nothing
finish_progress!(::NoLogging) = nothing
get_n_updates(::NoLogging) = 200
get_n_updates(::NoLogging) = DEFAULT_N_UPDATES

"""
ExistingProgressBar
Expand Down Expand Up @@ -72,7 +74,7 @@ end
function finish_progress!(p::ExistingProgressBar)
ProgressLogging.@logprogress p.name "done" _id = p.uuid
end
get_n_updates(::ExistingProgressBar) = 200
get_n_updates(::ExistingProgressBar) = DEFAULT_N_UPDATES

"""
ChannelProgress
Expand Down
20 changes: 9 additions & 11 deletions src/sample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,12 @@ function mcmcsample(
progress_channel = Channel{Bool}(nchains)
overall_progress_bar = CreateNewProgressBar(progressname)
# If we have many chains and many samples, we don't want to force
# each chain to report back to the main thread for each sample, as
# this would cause serious performance issues due to lock conflicts.
# In the overall progress bar we only expect 200 updates (i.e., one
# update per 0.5%). To avoid possible throttling issues we ask for
# twice the amount needed per chain, which doesn't cause a real
# performance hit.
updates_per_chain = max(1, 400 ÷ nchains)
# each chain to report back to the main thread for each sample, as this would
# cause serious performance issues due to lock conflicts. In the overall
# progress bar we only expect N updates (by default N = 200, i.e., one update
# per 0.5%). To avoid possible throttling issues we ask for twice
# the amount needed per chain, which doesn't cause a real performance hit.
updates_per_chain = max(1, (2 * get_n_updates(overall_progress_bar)) ÷ nchains)
init_progress!(overall_progress_bar)
end
if progress == :perchain
Expand All @@ -483,7 +482,7 @@ function mcmcsample(
Ntotal = nchains * updates_per_chain
# Determine threshold values for progress logging
# (one update per 0.5% of progress)
threshold = Ntotal / 200
threshold = Ntotal / get_n_updates(overall_progress_bar)
next_update = threshold

itotal = 0
Expand Down Expand Up @@ -633,7 +632,7 @@ function mcmcsample(
overall_progress_bar = CreateNewProgressBar(progressname)
init_progress!(overall_progress_bar)
# See MCMCThreads method for the rationale behind updates_per_chain.
updates_per_chain = max(1, 400 ÷ nchains)
updates_per_chain = max(1, (2 * get_n_updates(overall_progress_bar)) ÷ nchains)
child_progresses = [
ChannelProgress(progress_channel, updates_per_chain) for _ in 1:nchains
]
Expand All @@ -646,9 +645,8 @@ function mcmcsample(
# This task updates the progress bar
Distributed.@async begin
# Determine threshold values for progress logging
# (one update per 0.5% of progress)
Ntotal = nchains * updates_per_chain
threshold = Ntotal / 200
threshold = Ntotal / get_n_updates(overall_progress_bar)
next_update = threshold

itotal = 0
Expand Down
Loading