-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix GC stress log and analysis #108655
Open
markples
wants to merge
23
commits into
dotnet:main
Choose a base branch
from
markples:stresslog-gcstart
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−67
Open
Fix GC stress log and analysis #108655
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
25d4301
Allow floats to be recorded into the stresslog on 64-bit platforms (a…
jkoritzinsky 665f79c
change gc start message and some factoring
markples de54a94
quick fix to allowing gcstart to be a prefix
markples 33fae84
StressLogAnalyzer - handle 16 format arguments and avoid buffer overruns
markples 89e78d6
comment
markples e4fb843
get_str_gc_type and remove non-BGC special cases
markples be5e9a7
fix
markples 2a50341
TRACE_GC off
markples 200d2c7
enable by default
markples 11a54ee
not always
markples 3c37b03
LL_INFO1000 for 'Segment mem' message
markples a02f9cd
fewer messages
markples e75c257
fewer messages
markples 9cf150a
remove sizeof
markples a18b04f
Handle %3s
markples 018d47c
comment
markples ea970dd
comment
markples 50eb8bd
See if stresslog.h STRESS_LOG_VA is unnecessary
markples 60a3754
_DEBUG
markples 257699a
Revert "See if stresslog.h STRESS_LOG_VA is unnecessary"
markples 6d53869
redo ifdef
markples b920fa3
move a few more dprintfs to 2
markples ce7214c
comments
markples File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,9 +344,23 @@ inline bool IsServerHeap() | |
#define MAX_LONGPATH 1024 | ||
#endif // MAX_LONGPATH | ||
|
||
// #define TRACE_GC | ||
// TRACE_GC has two sub-modes: the standard VM stress log mechanism and | ||
// SIMPLE_DPRINTF, which is text output. By default, we enable TRACE_GC (not | ||
// SIMPLE_DPRINTF) for debug/checked builds so that we can catch build breaks. | ||
// HOST_64BIT is required because logging dprintf to the stress log us only | ||
// supported on 64 bit platforms. We could consider enabling it in release | ||
// builds and for more logging sites (see below for details) but are being | ||
// conservative about performance impact. | ||
// | ||
// Normal development time changes are to enable SIMPLE_DPRINTF here (which | ||
// will automatically set TRACE_GC) or to only enable TRACE_GC. | ||
|
||
// #define SIMPLE_DPRINTF | ||
|
||
#if defined(SIMPLE_DPRINTF) || (defined(_DEBUG) && defined(HOST_64BIT)) | ||
#define TRACE_GC | ||
#endif // _DEBUG | ||
|
||
#ifdef TRACE_GC | ||
#define MIN_CUSTOM_LOG_LEVEL 7 | ||
#define SEG_REUSE_LOG_0 (MIN_CUSTOM_LOG_LEVEL) | ||
|
@@ -375,10 +389,79 @@ HRESULT initialize_log_file(); | |
void flush_gc_log (bool); | ||
void GCLog (const char *fmt, ... ); | ||
#define dprintf(l,x) {if ((l == 1) || (l == GTC_LOG)) {GCLog x;}} | ||
#define SIMPLE_DPRINTF_ARG(x) , x | ||
|
||
#else //SIMPLE_DPRINTF | ||
|
||
#ifdef HOST_64BIT | ||
#define dprintf(l,x) STRESS_LOG_VA(l,x); | ||
|
||
// ------------------------------- | ||
// Stress log / dprintf background | ||
// ------------------------------- | ||
// | ||
// This code connects dprintf to the stress log mechanism. These machanisms | ||
// and their usage has evolved a bit separately over time, so there are some | ||
// rough edges here. | ||
// | ||
// The stress log mechanism has a LogFacility and a LogLevel. Facilities can be | ||
// chosen through DOTNET_LogFacility, and the facility is recorded in the | ||
// stress log. LogFacility is a bitmask. The GC only has a few bits reserved | ||
// in the bitmask, and most GC logging uses a single value (LF_GC, which is 0x1). | ||
// | ||
// The stress log logging level can be chosen through DOTNET_LogLevel. This | ||
// causes filtering at runtime, and the level is not recorded in the stress log. | ||
// The first argument to dprintf is similar, though it can record either a level | ||
// (values below 7) or a GC area (values starting with SEG_REUSE_LOG_0 above). | ||
// Developers often use StressLogAnalyzer to filter by this value at _analysis_ | ||
// time, which doesn't match usual stress log usage. | ||
// | ||
// In practice, dprintf(1) and LL_INFO10 (which has the value 4) have been used | ||
// similarly on log messages. A dprintf(1) is generally called about once per | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. few |
||
// GC, and LL_INFO10 is "10 logs per small but not trivial run". Other values | ||
// have been audited. We could consider moving the GC values to be in line with | ||
// the rest of the runtime (change 1 to 4 to make room for errors/warnings, etc.) | ||
// or (to avoid churn) convert them by adding 3. | ||
// | ||
// To allow StressLogAnalyzer to use the GC level values, we abuse the stress | ||
// log LogLevel by storing the GC value in the upper 16 bits of LogLevel and | ||
// also settings LF_GC (0x1). This works because we don't enable other logging | ||
// when doing GC investigations. However, we don't want to do this by default | ||
// because setting the upper bits will cause GC logging to masquerade as non-GC | ||
// logging. For example, dprintf(3) would use (3 << 16) | LF_GC == 0x30001, | ||
// which is LF_ASSERT | LF_VERIFIER | LF_GC in other contexts. | ||
// | ||
// Lastly, we have GC logging for some very low level operations, so by default | ||
// we don't want to even have the check that logging is enabled for performance | ||
// reasons. Right now we are very conservative and only allow dprintf(1) to go | ||
// to the stress log in default builds, but we could consider allowing more in | ||
// the future. | ||
|
||
// ----------------------------- | ||
// Stress log / dprintf settings | ||
// ----------------------------- | ||
// | ||
// (See above for details.) | ||
// | ||
// The following line works for normal debug/checked builds (where STRESS_LOG is | ||
// defined and SIMPLE_DPRINTF is not). All dprintf sites are checked for | ||
// compilation errors, yet all but those with level 1 can be statically | ||
// optimized away. In the future after more auditing, this could be expanded to | ||
// more levels. | ||
// | ||
// Note that zero is passed because STRESS_LOG_VA/LogMsg will add LF_GC and in | ||
// normal builds we don't want conflicts in the upper bits of LogFacility. | ||
#define dprintf(l,x) if (l == 1) {STRESS_LOG_VA(0,x);} | ||
|
||
// For private builds where it is ok (and useful) to have conflicts in the upper | ||
// bits of LogFacility, more events can be allowed and the dprintf level can be | ||
// passed through. Usually this is going to be a GC investigation and the other | ||
// logging will be disabled, so the theoretical conflict won't happen in | ||
// practice. Note that in these examples, 'l' ("ell", not "one") is passed | ||
// rather than '0'. | ||
//#define dprintf(l,x) STRESS_LOG_VA(l,x); | ||
//#define dprintf(l,x) {if ((l <= 2) || (l == 6666)) {STRESS_LOG_VA(l,x);}} | ||
|
||
#define SIMPLE_DPRINTF_ARG(x) | ||
#else //HOST_64BIT | ||
#error Logging dprintf to stress log on 32 bits platforms is not supported. | ||
#endif //HOST_64BIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is