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

Mention in Gc documentation that compaction is currently not implemented. #11816

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

abbysmal
Copy link
Contributor

I decided to go with #11812 step-by-step, and this PR is the first one.

This simply addresses the first point: annotate documentation for compaction related functions and stating that compaction is currently not available since release 5.0.

@abbysmal abbysmal changed the title Mention in Gc documentation that compaction is currently note implemented. Mention in Gc documentation that compaction is currently not implemented. Dec 14, 2022
Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

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

I don't mind if the code change parts of this want splitting off elsewhere (assuming they're wanted). I would tend to describe what the functions do now, rather than what they used to do as well

stdlib/gc.mli Outdated
Comment on lines 82 to 84
(** Note: As of OCaml 5.0, compaction is not available and this field's
value will always be zero.
Number of heap compactions since the program was started. *)
Copy link
Member

Choose a reason for hiding this comment

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

I would remove the last sentence - i.e. we just state that it's always zero because compaction was removed.

stdlib/gc.mli Outdated
Comment on lines 148 to 150
(** Note: As of OCaml 5.0, compaction is not implemented, and this field
will have no effect.
Heap compaction is triggered when the estimated amount
Copy link
Member

Choose a reason for hiding this comment

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

For the control words, I think this ought to be stronger - i.e. "must be zero" and Gc.set should raise Invalid_argument if it's not zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to me that raising Invalid_argument is a bit strong?
Isn't there a middle ground where we could notify users this is not taken into account without breaking their programs?

Copy link
Member

Choose a reason for hiding this comment

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

My rationale is that these functions should be being called correctly - i.e. that it's a programming error to call Gc.set with an invalid set of parameters for a given version of OCaml (i.e. the user's program is broken, whether or not we raise an exception!). It doesn't seem right to me to be silently dropping the incorrect configuration request, at which point the only option is an exception and Invalid_argument seems more appropriate here than Failure?

Comment on lines +307 to +309
(** Note: As of OCaml 5.0, compaction is not implemented, and calling this
function will only trigger a major collection.
Perform a full major collection and compact the heap. Note that heap
Copy link
Member

Choose a reason for hiding this comment

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

I was going to suggest that this should presumably be equivalent to Gc.full_major ... but in fact it looks like there's a bug in the implementation, as the C code appears only to do a major GC slice!

@abbysmal
Copy link
Contributor Author

abbysmal commented Jan 5, 2023

@dra27 Thanks for your feedback. I made some adjustment following your comments, let me know if it looks better.

@kayceesrk
Copy link
Contributor

This is relevant: #12193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants