-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Measure USS on Linux #744
Measure USS on Linux #744
Conversation
Mmmm I'm skeptical about this because it introduces a considerable slowdown. Also, at the current state this can already be determined by using |
...on the other hand it seems USS is very useful, as it reflects the real memory used by the process: |
Before the patch:
After the patch:
That's why I was worried about performances. |
It's possible the implementation could be made more efficient, I haven't put much effort into that. Given the usefulness of the measurement and the availability of Manually iterating over the values from re: PSS, it could be measured though the same method as well and could certainly be added in a follow up. |
AFAIK the only way Linux exposes this info is via |
I tried out regex, reading the whole file, and using |
Can you post the regex code? |
p = re.compile("Private.*:\s+(\d+)")
with open_text("%s/%s/smaps" % (self._procfs_path, self.pid),
buffering=BIGGER_FILE_BUFFERING) as f:
private = 0
for x in f:
m = p.match(x)
if m:
private += int(m.group(1))
return private * 1024 |
No I was suggesting to try one (single) regex against the whole data (as in |
That's a bit better:
|
Code? |
p = re.compile("Private.*:\s+(\d+)")
with open_text("%s/%s/smaps" % (self._procfs_path, self.pid),
buffering=BIGGER_FILE_BUFFERING) as f:
return sum(map(int,p.findall(f.read()))) * 1024 |
I found this: |
See this note from the Firefox source. |
@giampaolo At this point do you want to take this (and the other platforms)? I can do a Mozilla specific fork if you don't, but I'd prefer not to. Another option is to split the USS measurement into it's own function, although it seems to make the most sense in |
@EricRahm I definitively want this, I'm just unsure about how to provide this in terms the API, since it introduces such a huge slowdown. I was thinking that maybe we could control this via a specific parameter (something like Also, in the long term, I would also like to provide PSS. |
In the end I think it makes sense to integrate this into As for this PR: it can be closed as I've just committed 7f0e093 which also provides PSS. @EricRahm I reviewed your other 2 PRs for OSX and Windows which I would like to merge soon. |
After a lot of thinking I came up to the conclusion that it is not convenient to calculate these metrics into |
This adds the measurement of USS (unique set size) to
memory_info_ex
on Linux. General logic was adapted from Firefox's memory measurement subsystem.