-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TSan] Unlocking MonoStats, GCStats and JITGCStats #5381
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
[TSan] Unlocking MonoStats, GCStats and JITGCStats #5381
Conversation
|
@cherusker, |
mono/metadata/sgen-mono.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BrzVlad is the size arg of sgen_client_degraded_allocation not useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything starting with sgen_client_ is part of the SGen API, so this is a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexrp I don't think these are meant to be an official API and they were changed in the past. Are there other runtimes out there that actually use sgen in the first place ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess @schani would know. He did the whole SGen separation effort for a use case I can't remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this is fine.
mono/utils/unlocked.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split the changes to this file into a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexrp sure; done!
4e37630 to
435c428
Compare
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luhenry can we compare with == GENERATION_NURSERY here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you can. also, you can use Interlocked here.
|
A lot of the counters are in somewhat perf sensitive code, you don't want an atomic operation every time an object etc. is created for example. The ones in the JIT are ok. |
|
@vargaz the |
|
The non-perf critical ones can use the simple Interlocked functions. |
lewurm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I annotated all sites that I think aren't performance critical and thus can use Interlocked. In general, I think most of the stuff in your PR isn't perf-critical, except the JIT info lookup and IMT machinery. @vargaz can you have a look again and check if my assessment is correct?
mono/metadata/boehm-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/metadata/boehm-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vargaz @lewurm can I convert the gc_stats.*_gc_time_* values (gc-internal-agnostic.h) to gint64? The reason behind this: An InterlockedAdd64 () function exists already, however, I would have to "invent" InterlockedAddUnsigned64 (). Furthermore, @vargaz told me to simply use signed types if there is no explicit reason for using unsigned ones (#5299) and 9,223,372,036,854,775,807 ns are still almost 300 years ... do we really need 600 years?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fine. also, mono_100ns_ticks () returns a gint64.
mono/metadata/loader.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/metadata/sgen-mono.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything can use Interlocked here
mono/mini/driver.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be Interlocked
mono/sgen/sgen-gc.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you can. also, you can use Interlocked here.
- add functions for upcoming commits
- add `InterlockedWriteBool ()` which will be used in an upcoming commit
- change field types from `size_t` to `gint32` - GLib types are preferably used throughout Mono - `Interlocked* ()` functions exist for `gint32` already - `gint32` is preferred to `gint64` when looking at 32-bit machines - the extra 2,147,483,648 (0 <= `size_t` <= 4,294,967,295; -2,147,483,648 <= `gint32` <= 2,147,483,647) don't seem to matter when looking at the average values of these variables - remove unused fields; some fields have been moved to GCStats (`*_gc_*`) - use `G_*_FORMAT` to correctly print `g*` types
- `minor_gc_count` and `major_gc_count`: use `gint32` as the `binary_protocol_collection* ()` and `sgen_debug_dump_heap ()` functions cast these values to `int` anyways - `*_gc_time_*`: use `gint64` since 300 years seem like a fair amount of time and `Interlocked*64 ()` can be used - adjust the logic of `sgen_gc_collection_count ()` to enhance its readability - parameter `size` of `sgen_client_degraded_allocation` is unused and can be removed - use `Interlocked* ()` for static variables of `sgen_client_degraded_allocation ()` - use `G_*_FORMAT` to correctly print `g*` types
- change the field types from `int` to `gint32`
435c428 to
441a6f6
Compare
| /* The following functions cannot be found on any platform, and thus they can be declared without further existence checks */ | ||
|
|
||
| static inline void | ||
| InterlockedWriteBool (volatile gboolean *dest, gboolean val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
The most recent update changed a lot of functions from
|
|
I think we should use either gint32 or gint64, depending on the expected values. |
|
@vargaz I have seen these values going into the low millions but always staying far away from the billions with |
|
I think gint64 is only needed for things like amount of GC memory allocated. |
|
@monojenkins squash |
[TSan] Unlocking MonoStats, GCStats and JITGCStats As the `Unlocked* ()` functions have been approved in mono/mono#5310, I used them to blacklist some of the most obvious counting variables whose data races should be ignored: `MonoStats`, `GCStats` and `JITGCStats` (more to follow if approved). Please find details about all changes within the commit messages. Commit migrated from mono/mono@787faec
As the
Unlocked* ()functions have been approved in #5310, I used them to blacklist some of the most obvious counting variables whose data races should be ignored:MonoStats,GCStatsandJITGCStats(more to follow if approved).Please find details about all changes within the commit messages.