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

Update stats at the end of a major cycle (and potentially a compaction) #12850

Merged
merged 5 commits into from
Dec 21, 2023

Conversation

sadiqj
Copy link
Contributor

@sadiqj sadiqj commented Dec 20, 2023

Small change but one that bit me last week. This PR adds an additional caml_collect_gc_stats_sample_stw to the major heap cycling stw. This means that Gc.quick_stat now actually reflects the state of the heap after a major cycle or compaction.

runtime/major_gc.c Outdated Show resolved Hide resolved
sadiqj and others added 2 commits December 20, 2023 14:25
Co-authored-by: Miod Vallat <118974489+dustanddreams@users.noreply.github.com>
Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

I checked that the synchronization looks correct: this is running during a critical STW section, on all domains.

I am wondering about the placement of this call, however. This is below a conditional call to the compaction logic, and the comment says "this is useful for example if compaction happened":

  • Is this useful only if compaction happened, in which case I would suggest moving it inside the compaction code (possibly at the end of the COMPACT_RELEASE phase)?
  • or is it useful for some other reasons, which ones?

Minor comment: the definition of sampled_gc_stats in gc_stats.c has a comment that explains that stats are updated on each minor collection, which is invalidated by the present change. It could either be kept up-to-date by adding "and after each {compaction, major cycle}", or possibly be made vaguer.

@sadiqj
Copy link
Contributor Author

sadiqj commented Dec 20, 2023

Thanks for taking a look @gasche

Is this useful only if compaction happened, in which case I would suggest moving it inside the compaction code (possibly at the end of the COMPACT_RELEASE phase)?

A major slice may result in the pool words / live words stats changing. We can't also put an update in to major_collection_slice because it's not always in a stw.

Minor comment: the definition of sampled_gc_stats in gc_stats.c has a comment that explains that stats are updated on each minor collection, which is invalidated by the present change. It could either be kept up-to-date by adding "and after each {compaction, major cycle}", or possibly be made vaguer.

Updated the comment in f1183fc

@dra27 dra27 merged commit b8b2def into ocaml:trunk Dec 21, 2023
9 checks passed
@dra27
Copy link
Member

dra27 commented Dec 21, 2023

I took the lack of a comment between gasche's review and approval as meaning he did not require being added to the list of reviewers in Changes ... if that's wrong, please push to trunk 🙂

@gasche
Copy link
Member

gasche commented Dec 21, 2023

I rarely explicitly require to be added as a reviewer (it's a fairly unpleasant thing to do), but I believe that it would have been the right thing to do in this case as I did an actual review. Of course I agree that this is just fine as I will push to trunk. I failed to be explicit about should be done before merging, mostly because I hadn't done the job myself of wondering about this.

@dra27
Copy link
Member

dra27 commented Dec 21, 2023

I have updated my mental model for next time - although I would say that "Please can I be added to the list of reviewers in the Changes entry" shouldn't be too bad a thing to have to ask!

@sadiqj
Copy link
Contributor Author

sadiqj commented Dec 21, 2023

Oops, was just getting around to updating Changes and merging, have seen you've beat me too it. Thanks for the review @gasche .

@shindere
Copy link
Contributor

shindere commented Dec 21, 2023 via email

@gasche
Copy link
Member

gasche commented Dec 21, 2023

It's a delicate social balance. The question of what comments "count" as reviews is highly subjective and I think that it is better to rely on the committers' best judgment than trying to nudge them using automated processes. (For example: would people feel comfortable not following the recommendation of such an automated tools for comments that do not correspond to an actual review effort?)

@shindere
Copy link
Contributor

shindere commented Dec 21, 2023 via email

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.

None yet

5 participants