-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-115720: Show number of leaks in huntrleaks progress reports #115726
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 |
---|---|---|
|
@@ -88,9 +88,12 @@ def get_pooled_int(value): | |
rc_before = alloc_before = fd_before = interned_before = 0 | ||
|
||
if not quiet: | ||
print("beginning", repcount, "repetitions", file=sys.stderr) | ||
print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr, | ||
flush=True) | ||
print("beginning", repcount, "repetitions. Showing number of leaks " | ||
"(. for 0 or less, X for 10 or more)", | ||
file=sys.stderr) | ||
numbers = ("1234567890"*(repcount//10 + 1))[:repcount] | ||
numbers = numbers[:warmups] + ':' + numbers[warmups:] | ||
print(numbers, file=sys.stderr, flush=True) | ||
|
||
results = None | ||
dash_R_cleanup(fs, ps, pic, zdc, abcs) | ||
|
@@ -116,13 +119,27 @@ def get_pooled_int(value): | |
rc_after = gettotalrefcount() - interned_after * 2 | ||
fd_after = fd_count() | ||
|
||
if not quiet: | ||
print('.', end='', file=sys.stderr, flush=True) | ||
|
||
rc_deltas[i] = get_pooled_int(rc_after - rc_before) | ||
alloc_deltas[i] = get_pooled_int(alloc_after - alloc_before) | ||
fd_deltas[i] = get_pooled_int(fd_after - fd_before) | ||
|
||
if not quiet: | ||
# use max, not sum, so total_leaks is one of the pooled ints | ||
total_leaks = max(rc_deltas[i], alloc_deltas[i], fd_deltas[i]) | ||
if total_leaks <= 0: | ||
symbol = '.' | ||
elif total_leaks < 10: | ||
symbol = ( | ||
'.', '1', '2', '3', '4', '5', '6', '7', '8', '9', | ||
)[total_leaks] | ||
else: | ||
symbol = 'X' | ||
if i == warmups: | ||
print(' ', end='', file=sys.stderr, flush=True) | ||
print(symbol, end='', file=sys.stderr, flush=True) | ||
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. To avoid any risk of side effect of that code, I suggest to add a get_symbol() function which would look into a pre-computed array for values <= 10. Something like: symbols = ['.'] + [str(i) for i in range(1, 10)] + ['X']
def get_symbol(value):
return symbols[min(max(value, 0), 10)] |
||
del total_leaks | ||
del symbol | ||
|
||
alloc_before = alloc_after | ||
rc_before = rc_after | ||
fd_before = fd_after | ||
|
@@ -158,14 +175,20 @@ def check_fd_deltas(deltas): | |
]: | ||
# ignore warmup runs | ||
deltas = deltas[warmups:] | ||
if checker(deltas): | ||
failing = checker(deltas) | ||
suspicious = any(deltas) | ||
if failing or suspicious: | ||
msg = '%s leaked %s %s, sum=%s' % ( | ||
test_name, deltas, item_name, sum(deltas)) | ||
print(msg, file=sys.stderr, flush=True) | ||
with open(filename, "a", encoding="utf-8") as refrep: | ||
print(msg, file=refrep) | ||
refrep.flush() | ||
failed = True | ||
print(msg, end='', file=sys.stderr) | ||
if failing: | ||
print(file=sys.stderr, flush=True) | ||
with open(filename, "a", encoding="utf-8") as refrep: | ||
print(msg, file=refrep) | ||
refrep.flush() | ||
failed = True | ||
else: | ||
print(' (this is fine)', file=sys.stderr, flush=True) | ||
return (failed, results) | ||
|
||
|
||
|
This file contains hidden or 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
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Tests/2024-02-20-15-47-41.gh-issue-115720.w8i8UG.rst
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Leak tests (``-R``, ``--huntrleaks``) now show a summary of the number of | ||
leaks found in each iteration. |
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.
This is lovely, thanks :-)