Last Comment Bug 1145007 - Add "resident-peak" memory measurement on Unix
: Add "resident-peak" memory measurement on Unix
Status: RESOLVED FIXED
[MemShrink]
:
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: unspecified
: x86_64 Linux
-- normal (vote)
: mozilla39
Assigned To: Nicholas Nethercote [:njn]
:
: Nathan Froyd [:froydnj]
Mentors:
Depends on:
Blocks: 1141672
  Show dependency treegraph
 
Reported: 2015-03-18 20:44 PDT by Nicholas Nethercote [:njn]
Modified: 2015-03-21 12:37 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
fixed


Attachments
(part 1) - Test |residentUnique| in test_memoryReporters.xul (1.16 KB, patch)
2015-03-18 20:58 PDT, Nicholas Nethercote [:njn]
erahm: review+
Details | Diff | Splinter Review
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Linux (7.41 KB, patch)
2015-03-18 20:59 PDT, Nicholas Nethercote [:njn]
no flags Details | Diff | Splinter Review
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Linux (7.58 KB, patch)
2015-03-18 22:26 PDT, Nicholas Nethercote [:njn]
erahm: review+
Details | Diff | Splinter Review
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Unix (9.42 KB, patch)
2015-03-19 15:30 PDT, Nicholas Nethercote [:njn]
erahm: review+
Details | Diff | Splinter Review

Description User image Nicholas Nethercote [:njn] 2015-03-18 20:44:27 PDT
This has been suggested several times recently. It can be read from the "VmHWM" entry in /proc/<pid>/status.
Comment 1 User image Nicholas Nethercote [:njn] 2015-03-18 20:58:53 PDT
Created attachment 8579805 [details] [diff] [review]
(part 1) - Test |residentUnique| in test_memoryReporters.xul

It is the only distinguished amount in nsIMemoryReporterManager that isn't
being tested.
Comment 2 User image Nicholas Nethercote [:njn] 2015-03-18 20:59:10 PDT
Created attachment 8579806 [details] [diff] [review]
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Linux
Comment 3 User image Mike Hommey [:glandium] 2015-03-18 21:30:22 PDT
Doesn't getrusage give the same value in ru_maxrss?
Comment 4 User image Nicholas Nethercote [:njn] 2015-03-18 22:23:45 PDT
(In reply to Mike Hommey [:glandium] from comment #3)
> Doesn't getrusage give the same value in ru_maxrss?

Oh, I didn't know about getrusage. It gives the same result and is easier to use, so I'll switch.
Comment 5 User image Nicholas Nethercote [:njn] 2015-03-18 22:26:34 PDT
Created attachment 8579838 [details] [diff] [review]
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Linux

Now using getrusage().
Comment 6 User image Mike Hommey [:glandium] 2015-03-18 23:07:23 PDT
Note that getrusage is POSIX, you can also use it on OSX as well (or even #ifdef XP_UNIX, likely)
Comment 7 User image Eric Rahm [:erahm] 2015-03-19 09:36:44 PDT
Comment on attachment 8579805 [details] [diff] [review]
(part 1) - Test |residentUnique| in test_memoryReporters.xul

Review of attachment 8579805 [details] [diff] [review]:
-----------------------------------------------------------------

r=me
Comment 8 User image Eric Rahm [:erahm] 2015-03-19 09:53:19 PDT
Comment on attachment 8579838 [details] [diff] [review]
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Linux

Review of attachment 8579838 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm. It would be nice to have this supported on OSX/BSD as well. Can you file a follow up for that?
Comment 9 User image Nicholas Nethercote [:njn] 2015-03-19 14:46:57 PDT
> It would be nice to have this supported on OSX/BSD as well. Can you
> file a follow up for that?

I'll just do it in this patch, by moving the peak stuff in nsMemoryReporterManager.cpp into a XP_UNIX block.
Comment 10 User image Nicholas Nethercote [:njn] 2015-03-19 15:30:25 PDT
Created attachment 8580322 [details] [diff] [review]
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Unix

ResidentPeakDistinguishedAmount() is now in the XP_UNIX section, and I'm
handling the different units for different Unices, and I'm handling the
possibility of 0, in case Solaris returns that.
Comment 11 User image Eric Rahm [:erahm] 2015-03-19 15:50:29 PDT
Comment on attachment 8580322 [details] [diff] [review]
(part 2) - Add a "resident-peak" distinguished amount and memory reporter on Unix

Review of attachment 8580322 [details] [diff] [review]:
-----------------------------------------------------------------

r=me, one super minor suggestion.

::: xpcom/base/nsMemoryReporterManager.cpp
@@ +810,5 @@
> +ResidentPeakDistinguishedAmount(int64_t* aN)
> +{
> +  struct rusage usage;
> +  if (0 == getrusage(RUSAGE_SELF, &usage)) {
> +    // The units for ru_maxrrs:

nit: ru_maxrss

@@ +1923,5 @@
> +
> +/*static*/ int64_t
> +nsMemoryReporterManager::ResidentPeak()
> +{
> +#ifdef HAVE_RESIDENT_PEAK_REPORTER

min--: This could just call GetResidentPeak and drop the #ifdefs.
Comment 12 User image Nicholas Nethercote [:njn] 2015-03-19 15:55:05 PDT
> > +/*static*/ int64_t
> > +nsMemoryReporterManager::ResidentPeak()
> > +{
> > +#ifdef HAVE_RESIDENT_PEAK_REPORTER
> 
> min--: This could just call GetResidentPeak and drop the #ifdefs.

I thought that too, but this one is static and GetResidentPeak() is not.

Note You need to log in before you can comment on or make changes to this bug.