-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] Global settings/defaults #71
Comments
This seems like a good idea. Global variables are a bit of an issue for composability and general usage (e.g. someone using Current:
Proposed:
And if you've asked to spend a little longer on benchmarks to get more accurate results and an optimization function author uses Here are some plausible names: Charimarks.DEFAULTS.seconds = 1
Charimarks.DEFAULT_PARAMETERS.seconds = 1
Charimarks.DEFAULT_SECONDS[] = 1 I prefer the foremost name because it is formulaic and I think it's unambiguous. What other defaults could we possibly have? The second name is what BenchmarkTools.jl uses, but making the same design choices as BenchmarkTools is not a priority for this package. |
Nice! I agree the first one looks best. |
I agree. |
Okay, another thought: what if these defaults are module/Main specific? For example, if BaseBenchmarks uses Chairmarks, I don't really want BaseBenchmarks to have to worry about whether users are going to define new defaults. Because Then we have some more options: Chairmarks.DEFAULTS.seconds = 1 # Effects only Main
Chairmarks.DEFAULTS[Mod].seconds = 1 # Effects only Mod
Chairmarks.@set_default seconds = 1 samples = 10_000 # Effects only the module that this macro was called in |
That would be difficult to set with Documenter, because it creates a new module for every I do get the appeal of module-specific settings, though. How about this: if a module specific setting is not detected, then it falls back to the settings for |
The default parameters for BenchmarkTools are named so how about using |
For the Documenter usecase, a scoped value set with Charimarks.with_defaults(seconds = 1) do
makedocs(...)
end would work. It would be possible to have a whole hierarchy Function arguments > Scoped values > Module defaults > Globals > Chairmark's defaults Which is altogether too many ways to pass an argument to a function. We already have (and ought to keep) function arguments and Charimark's defaults. Module defaults are the least invasive thing to put in users' startup.jl files and scoped values are the least invasive thing to support reconfiguring defaults for Documentation deployment. Scoped values are also ideal for BaseBenchmarks usage. Plain globals are the best thing for RegressionTests.jl, though. I want to set the default runtime to .01 due to the outer loop that that package employs, globals are safe because RegressionTests is working with self-contained Julia processes that is spawns and owns, and globals are better than scoped values because they don't require special invocation by the user. Given that plain globals are needed by at least one use case and that globals can imitate scoped values and module-specific globals while the reverse is not the case, I suppose it makes sense to implement globals now and only implement the others if global conflicts become an issue. |
I noticed that there was some instability when benchmarking functions with a runtime of ~3ms, which was reduced significantly when I set
seconds=1
.Would it be possible to set "global defaults" when using Chairmarks, so that I could set the default value of
seconds
to be 1s instead of 0.1s?The text was updated successfully, but these errors were encountered: