Skip to content
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

feat: add JULIA_PKG_GC_AUTO env var #3642

Merged
merged 5 commits into from
Jul 25, 2024

Conversation

pfitzseb
Copy link
Member

@pfitzseb pfitzseb commented Oct 4, 2023

This PR adds a JULIA_PKG_DISABLE_AUTO_GC environment variable to allow users to disable automatic garbage collection without reaching into Pkg's internals and setting _auto_gc_enabled[] = false manually.

@ericphanson
Copy link
Contributor

This should get documented here too: https://docs.julialang.org/en/v1/manual/environment-variables/#Pkg.jl

src/Pkg.jl Outdated Show resolved Hide resolved
pfitzseb and others added 2 commits October 4, 2023 15:21
Co-authored-by: Eric Hanson <5846501+ericphanson@users.noreply.github.com>
@pfitzseb
Copy link
Member Author

pfitzseb commented Oct 4, 2023

-> JuliaLang/julia#51583

@pfitzseb pfitzseb requested a review from ericphanson October 4, 2023 17:17
Copy link
Contributor

@ericphanson ericphanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! it could be nice to dynamically check before doing auto GC's rather than setting it in __init__ so one can set the ENV variable later. But this already seems an improvement so IMO that shouldn't block merging.

@staticfloat
Copy link
Member

so one can set the ENV variable later.

I think the general pattern of ENV["JULIA_PKG_xxx"] = "false" in scripts should be discouraged, and Pkg._auto_gc_enabled[] = false should be encouraged for these reasons:

  • Environment variables are not thread safe and so should generally be thought of as a communication mechanism from outside of Julia to inside of Julia, not communication for things within Julia itself.
  • Priority can be difficult to determine; if ENV["JULIA_PKG_DISABLE_AUTO_GC"] is set to 1, but then the user later sets _auto_gc_enabled[] = true, which one wins? In the current setup, this is clear (_auto_gc_enabled[] is the ground truth, it copies the value of ENV["JULIA_PKG_DISABLE_AUTO_GC"] at __init__() and then the value is thereafter ignored).

staticfloat
staticfloat previously approved these changes Oct 4, 2023
@pfitzseb
Copy link
Member Author

pfitzseb commented Oct 4, 2023

Yeah, that second point is also what I was mostly concerned about.
Might be worth adding a function to set _auto_gc_enabled without touching that very internal looking ref, e.g. Pkg.API.auto_gc(::Bool). Thoughts?

@fingolfin
Copy link
Member

This was approved almost a year ago, but not merged. What gives?

@DilumAluthge
Copy link
Member

DilumAluthge commented Jul 24, 2024

@staticfloat Is this good to merge once CI passes?

@DilumAluthge
Copy link
Member

Also bump @pfitzseb

@fredrikekre
Copy link
Member

Should it be JULIA_PKG_AUTO_GC=true/false instead?

@IanButterworth
Copy link
Member

Yeah like JULIA_PKG_PRECOMPILE_AUTO=false

@IanButterworth
Copy link
Member

Or JULIA_PKG_GC_AUTO to match the order

@pfitzseb
Copy link
Member Author

Renamed the env var and added API.auto_gc function for getting and setting the _auto_gc_enabled state.

src/API.jl Outdated Show resolved Hide resolved
and rename env var to JULIA_PKG_GC_AUTO
@pfitzseb pfitzseb force-pushed the sp/julia_pkg_disable_auto_gc branch from 4d81d2c to 62fe923 Compare July 25, 2024 09:18
@IanButterworth IanButterworth changed the title feat: add JULIA_PKG_DISABLE_AUTO_GC env var feat: add JULIA_PKG_GC_AUTO env var Jul 25, 2024
@IanButterworth IanButterworth merged commit 3f81d6c into master Jul 25, 2024
7 checks passed
@IanButterworth IanButterworth deleted the sp/julia_pkg_disable_auto_gc branch July 25, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants