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

Move gc and gc_enable to their own module #25616

Merged
merged 2 commits into from
Jan 19, 2018

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jan 17, 2018

We document that these functions should not generally be used, and yet they're exported from Base. This PR moves the two functions into their own submodule, Base.GC. It seems a little silly to me that we say, "Here are these functions in your namespace, but you really shouldn't call them." Apparently they've been exported since Julia 0.1, so I imagine it's sort of a historical artifact at this point.

@ararslan ararslan added GC Garbage collector kind:deprecation This change introduces or involves a deprecation status:triage This should be discussed on a triage call labels Jan 17, 2018
@KristofferC
Copy link
Sponsor Member

KristofferC commented Jan 17, 2018

Just unexport them? Seems silly to have a whole module just for this...

@JeffBezanson
Copy link
Sponsor Member

JeffBezanson commented Jan 17, 2018

I agree just unexporting them is fine. But if we want the module, I prefer the name GC. Then we could have GC.enable instead of gc_enable.

@ararslan
Copy link
Member Author

Okay, then would you prefer no module or a module named GC? I'm pretty indifferent.

@ararslan ararslan mentioned this pull request Jan 17, 2018
19 tasks
@StefanKarpinski
Copy link
Sponsor Member

I think calling it GC and having GC.run() and GC.enable() would be preferable.

@JeffBezanson
Copy link
Sponsor Member

I'd prefer GC.gc() or GC.collect().

Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

I agree that these don't need to be in a module, then can just exist in Base. I'm not sure they really need to be unexported either. I would just update the docs to sound more informative and less scary.

base/gcutils.jl Outdated
Perform garbage collection.

!!! warning
This should not generally be used.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I think this is too strong. We probably should have just said "Excessive use will likely lead to poor performance". Being "not used often" (appropriate wording) and "should not generally be used" (current wording) don't quite express the same level of concern.

base/gcutils.jl Outdated
`false` for disabled). Return previous GC state.

!!! warning
Disabling garbage collection should be used only with extreme caution, as it can cause
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

delete "extreme"

@ararslan
Copy link
Member Author

ararslan commented Jan 18, 2018

Documentation updated. This now puts gc and gc_enable into Base.GC as GC.gc and GC.enable, and exports the GC module from Base. gc is exported from GC, so if you do using GC you get gc but not enable.

@ararslan ararslan force-pushed the aa/stop-exporting-gc-stuff branch 2 times, most recently from b59970e to aae96d0 Compare January 18, 2018 19:13
@StefanKarpinski StefanKarpinski added this to the 1.0 milestone Jan 18, 2018
@StefanKarpinski StefanKarpinski removed the status:triage This should be discussed on a triage call label Jan 18, 2018
@StefanKarpinski
Copy link
Sponsor Member

Good to go when it passes.

@ararslan
Copy link
Member Author

I'm having a hard time coming up with an appropriate deprecation for gc. Is it possible to @deprecate a function in Base and export it, but also export it from a Base submodule? What I'm trying to do is deprecate gc to GC.gc but let the user call gc unqualified if they've done using Base.GC. Currently using Base.GC gives an error saying that both Base and GC export gc.

@JeffBezanson
Copy link
Sponsor Member

I would suggest that people not write using Base.GC.

@ararslan
Copy link
Member Author

Fair enough.

@ararslan
Copy link
Member Author

Should we consider moving Base.@gc_preserve to Base.GC as GC.@preserve?

@ararslan ararslan changed the title Move gc and gc_enable to their own unexported module Move gc and gc_enable to their own module Jan 18, 2018
We document that these functions should not generally be used, and yet
they're exported from Base. This moves the two functions into their own
submodule, Base.GC, and deprecates the exported functions.
@JeffBezanson JeffBezanson merged commit 544e2ae into master Jan 19, 2018
@JeffBezanson JeffBezanson deleted the aa/stop-exporting-gc-stuff branch January 19, 2018 15:48
@stevengj
Copy link
Member

Would be good to have Compat support for these.

@martinholters
Copy link
Member

We have since JuliaLang/Compat.jl#477, except for @preserve.

@stevengj
Copy link
Member

@preserve is the one I needed 😬

@stevengj
Copy link
Member

Possibly Compat.GC.@preserve could just be a no-op in Julia 0.6, since that had a less aggressive garbage collector (see #23562)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector kind:deprecation This change introduces or involves a deprecation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants