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

chore: tool to aggregate allocator tracking logs #4439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tools/aggregate_allocator_tracking_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3

"""
Usage:
1. First run Dragonfly with tracking allocator enabled.
2. Finish tracking.
3. cat /tmp/dragonfly.INFO | ./aggregate_allocator_tracking_logs.py
"""

import sys


def aggregate(log_lines):
alloc_sum = 0
dealloc_sum = 0

for line in log_lines:
allocating = False
deallocating = False

for word in line.rstrip().split():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be a little bit more pythonic but oh well 🤷

if allocating:
alloc_sum = alloc_sum + int(word)
break
elif deallocating:
dealloc_sum = dealloc_sum + int(word)
break

if word == "Allocating":
allocating = True
if word == "Deallocating":
deallocating = True

print(f"Total allocations: {alloc_sum}\nTotal deallocations {dealloc_sum}")


if __name__ == "__main__":
log_lines = sys.stdin.readlines()
aggregate(log_lines)
2 changes: 1 addition & 1 deletion tools/parse_allocator_tracking_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
Usage:
1. First run Dragonfly with tracking allocator enabled. Must be a single allocator range with 100% samping rate to catch both allocations and deallocations.
1. First run Dragonfly with tracking allocator enabled. Must be a single allocator range with 100% sampling rate to catch both allocations and deallocations.
2. Finish tracking.
3. cat /tmp/dragonfly.INFO | ./parse_allocator_tracking_logs.py
"""
Expand Down
Loading