-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Base.MPFR: avoid reading the global defaults unless necessary #56095
Open
nsajko
wants to merge
1
commit into
JuliaLang:master
Choose a base branch
from
nsajko:mpfr_avoid_dereferencing_globals
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Oct 10, 2024
Fixes several issues: * Set `BigFloat` precision without mutating the global default, relying on the new ScopedValues functionality. * Avoid reading the global defaults for the precision and rounding mode, relies on JuliaLang#56095. * Try to ensure the loop terminates in a reasonable amount of time, and without trying to allocate excessively large `BigFloat` values.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Nov 6, 2024
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Nov 23, 2024
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Dec 3, 2024
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Dec 22, 2024
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
Another follow-up to JuliaLang#51362. Make sure the global default precision and rounding mode are only dereferenced when necessary (when there's no relevant scope, in the ScopedValues sense). Currently this change doesn't result in performance improvements, presumably due to how costly the access to a `ScopedValue` currently is, but the idea is to avoid the cost of the dereference when possible. Once ScopedValues are better optimized by the compiler, I guess this would also result in better effects in case it's known that a call is within a ScopedValues scope.
nsajko
force-pushed
the
mpfr_avoid_dereferencing_globals
branch
from
January 16, 2025 00:31
6075ac5
to
9117f64
Compare
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 16, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 16, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095.
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 23, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 23, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 23, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 24, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 26, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 29, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 30, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Feb 1, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Feb 2, 2025
Relying on `ScopedValues`, set `BigFloat` precision without mutating the global default, while constructing `Rational` from `AbstractIrrational`. Also helps avoid reading the global defaults for the precision and rounding mode, together with JuliaLang#56095. What does this fix: * in the case of the `Irrational` constants defined in `MathConstants`: relevant methods have `@assume_effects :foldable` applied, which includes `:effect_free`, which requires that no globals be mutated (followup on JuliaLang#55886) * in the case of `AbstractIrrational` values in general, this PR prevents data races on the global `BigFloat` precision
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Another follow-up to #51362.
Make sure the global default precision and rounding mode are only dereferenced when necessary (when there's no relevant scope, in the ScopedValues sense).
Currently this change doesn't result in performance improvements, presumably due to how costly the access to a
ScopedValue
currently is, but the idea is to avoid the cost of the dereference when possible.Once ScopedValues are better optimized by the compiler, I guess this would also result in better effects in case it's known that a call is within a ScopedValues scope.