Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Issue 173261: (Mac) Implement about:memory. (Closed)

Created:
11 years, 4 months ago by viettrungluu-gmail
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

(Mac) Implement about:memory. This implements about:memory on Mac. Moderately ridiculously, it calls top (in logging mode) to obtain information about processes (ps offers less information, and there aren't good -- or any, really -- APIs for this on Mac). Currently, we map the five available data (RPRVT, RSHRD, RSIZE, VPRVT, VSIZE) to the base::{CommittedKBytes, WorkingSetKBytes} structures which isn't entirely ideal. We then display the same about:memory page as Windows does, which may not be what we want either. BUG=9653 TEST=Go to about:memory under a variety of conditions (with a variety of browsers loaded).

Patch Set 1 #

Patch Set 2 : Rebased properly (sorry, git newbie). #

Patch Set 3 : Oops. Somehow I had forgotten about the histograms. #

Patch Set 4 : Rebased/merged with Linux about:memory refactoring. #

Patch Set 5 : Call top with a clean environment and limit how much is read from top. #

Patch Set 6 : Merged ToT. Updated/improved comments. #

Total comments: 16

Patch Set 7 : Updated per Thomas and Amanda's comments. #

Patch Set 8 : Renamed ProcessInfoFromTop, split into its own files, and added unit test. #

Patch Set 9 : Renamed SecureGetAppOutput() to GetAppOutputRestricted(); added unit test. #

Patch Set 10 : Make ProcessUtilTest.GetAppOutputRestricted posixly correct (I hope). #

Total comments: 50

Patch Set 11 : Work-in-progress; ignore the #if 0/#if 1's. #

Patch Set 12 : Rebased ToT (work still in progress). #

Patch Set 13 : Work in progress (still need Mac-specific about_memory.html). #

Patch Set 14 : Fully implemented to use ps; maybe reviewable? #

Patch Set 15 : Added comment giving TODOs an issue number. #

Total comments: 14

Patch Set 16 : Fixed stuff per jrg's review. #

Patch Set 17 : Fixed per jrg's (re)review. #

Patch Set 18 : Fixed per jrg's (re)review. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1332 lines, -53 lines) Patch
base/process_util.h View 5 6 7 8 9 10 11 12 1 chunk +8 lines, -0 lines 0 comments Download
base/process_util_posix.cc View 5 6 7 8 9 10 11 12 4 chunks +51 lines, -9 lines 0 comments Download
base/process_util_unittest.cc View 9 10 11 12 13 1 chunk +45 lines, -0 lines 0 comments Download
chrome/browser/browser_resources.grd View 14 15 1 chunk +4 lines, -2 lines 0 comments Download
chrome/browser/memory_details.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +13 lines, -0 lines 0 comments Download
chrome/browser/memory_details.cc View 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +30 lines, -25 lines 0 comments Download
chrome/browser/memory_details_mac.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +255 lines, -0 lines 0 comments Download
chrome/browser/process_info_snapshot.h View 8 9 10 11 12 13 14 15 1 chunk +106 lines, -0 lines 0 comments Download
chrome/browser/process_info_snapshot_mac.cc View 8 9 10 11 12 13 14 15 1 chunk +154 lines, -0 lines 0 comments Download
chrome/browser/process_info_snapshot_mac_unittest.cc View 8 9 10 11 12 13 14 15 1 chunk +85 lines, -0 lines 0 comments Download
chrome/browser/resources/about_memory_mac.html View 1 chunk +577 lines, -0 lines 0 comments Download
chrome/chrome.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +4 lines, -0 lines 0 comments Download
chrome/common/temp_scaffolding_stubs.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +0 lines, -17 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
viettrungluu-gmail
It's a start, and Nico's task manager patch is gated on this....
11 years, 2 months ago (2009-10-09 04:00:12 UTC) #1
Amanda Walker
LGTM with a couple of nits (the SIGPIPE question needs at least a TODO). I ...
11 years, 2 months ago (2009-10-09 15:39:30 UTC) #2
TVL
some quick comments, I didn't read to closely incase the svn cp comment makes sense, ...
11 years, 2 months ago (2009-10-09 15:43:40 UTC) #3
John Grabowski
-1 on LGTM without a unit tests to * confirm top output is what you ...
11 years, 2 months ago (2009-10-09 16:52:49 UTC) #4
viettrungluu-gmail
I still want to make a unit test. I'll ping when that's done. http://codereview.chromium.org/173261/diff/5001/5002 File ...
11 years, 2 months ago (2009-10-09 17:37:03 UTC) #5
Amanda Walker
On 2009/10/09 17:37:03, viettrungluu-gmail wrote: > Fair enough, though I'm at a loss for a ...
11 years, 2 months ago (2009-10-09 17:41:17 UTC) #6
viettrungluu-gmail
Okay, I renamed |ProcessInfoFromTop| to |ProcessInfoSnapshot| (mentioning top seemed a bit specific) and split it ...
11 years, 2 months ago (2009-10-09 22:37:04 UTC) #7
TVL
http://codereview.chromium.org/173261/diff/10008/9003 File base/process_util_posix.cc (right): http://codereview.chromium.org/173261/diff/10008/9003#newcode533 Line 533: DCHECK(do_search_path || envp); It took me a little ...
11 years, 2 months ago (2009-10-12 16:53:15 UTC) #8
Mark Mentovai
http://codereview.chromium.org/173261/diff/10008/9003 File base/process_util_posix.cc (right): http://codereview.chromium.org/173261/diff/10008/9003#newcode531 Line 531: // Either |do_search_path| should be false (x)or |envp| ...
11 years, 2 months ago (2009-10-12 18:14:55 UTC) #9
John Grabowski
trung: it may appear like it, but we are not ganging up on you. Collective ...
11 years, 2 months ago (2009-10-12 20:20:41 UTC) #10
viettrungluu
Work still in progress -- I've encountered some weirdness with |child_info| (as in, it's empty).... ...
11 years, 2 months ago (2009-10-14 05:33:05 UTC) #11
TVL
fyi - your replies are probably in reference to local code changes, since some of ...
11 years, 2 months ago (2009-10-14 13:55:14 UTC) #12
John Grabowski
All your comments sound reasonable; let me know when you're ready for re-review. jrg On ...
11 years, 2 months ago (2009-10-14 18:33:14 UTC) #13
viettrungluu
Argh. Apple completely revamped top for Snow Leopard, making it a very bad "API" to ...
11 years, 2 months ago (2009-10-15 22:28:30 UTC) #14
TVL
On Thu, Oct 15, 2009 at 6:28 PM, <viettrungluu@chromium.org> wrote: > Argh. Apple completely revamped ...
11 years, 2 months ago (2009-10-15 22:44:18 UTC) #15
viettrungluu
I've rewritten this to use /bin/ps instead, and I think it's ready for re-review. Do ...
11 years, 2 months ago (2009-10-21 23:34:41 UTC) #16
John Grabowski
Mostly "add comments" but the NACL_PROCESS thing needs to be fixed. Real close. http://codereview.chromium.org/173261/diff/22001/23005 File ...
11 years, 2 months ago (2009-10-22 20:57:06 UTC) #17
viettrungluu
11 years, 2 months ago (2009-10-23 02:14:49 UTC) #18
Somehow, I've messed things up and it won't upload properly anymore, so I'm
moving the patch here: <http://codereview.chromium.org/333008> (I can also
switch accounts at the same time). Sorry for the inconvenience.

http://codereview.chromium.org/173261/diff/22001/23005
File chrome/browser/memory_details.cc (right):

http://codereview.chromium.org/173261/diff/22001/23005#newcode211
Line 211: break;
On 2009/10/22 20:57:06, John Grabowski wrote:
> Looks like you accidentally removed NACL_PROCESS.  Please add back in.

Oops. Bad merge. Fixed.

http://codereview.chromium.org/173261/diff/22001/23007
File chrome/browser/memory_details_mac.cc (right):

http://codereview.chromium.org/173261/diff/22001/23007#newcode32
Line 32: class ProcessFilterByPID : public base::ProcessFilter {
Oops. This class was no longer used. It's now gone.

http://codereview.chromium.org/173261/diff/22001/23007#newcode88
Line 88: void MemoryDetails::CollectProcessData(
On 2009/10/22 20:57:06, John Grabowski wrote:
> Might want to add a comment "runs in the FILE thread so doesn't cause jank".  

Done.

http://codereview.chromium.org/173261/diff/22001/23007#newcode117
Line 117: // Get PIDs of helpers.
On 2009/10/22 20:57:06, John Grabowski wrote:
> Safari on 10.6 can have helpers (e.g. out-of-proc Flash32).  Look for those? 
> Generalize to have N names per browser?

I'll leave the for the grand multi-platform refactoring (see TODO near the top
of the file). I'll add a specific note about this in the bug.

http://codereview.chromium.org/173261/diff/22001/23007#newcode141
Line 141: // TODO(viettrungluu): properly get version/name info.
On 2009/10/22 20:57:06, John Grabowski wrote:
> Why is this a TODO?  Fix for Beta?  File a bug and add # here?

It wasn't super-simple, and it isn't idiot-proof, but I've fixed this.

http://codereview.chromium.org/173261/diff/22001/23007#newcode184
Line 184: // this blank!)
This one was easy to fix, so I did.

http://codereview.chromium.org/173261/diff/22001/23008
File chrome/browser/process_info_snapshot.h (right):

http://codereview.chromium.org/173261/diff/22001/23008#newcode24
Line 24: // should be considered opaque).
On 2009/10/22 20:57:06, John Grabowski wrote:
> Add brief comment explaining that top seems more useful but isn't portable
> between 10.5 and 10.6 (and makes us nervous about the future).

Done.

http://codereview.chromium.org/173261/diff/22001/23010
File chrome/browser/process_info_snapshot_mac_unittest.cc (right):

http://codereview.chromium.org/173261/diff/22001/23010#newcode83
Line 83: }
On 2009/10/22 20:57:06, John Grabowski wrote:
> Add a test which sanity checks your memory info.  E.g. compare our process
> against a "/bin/sleep 1" and make sure it has a larger vsize.

I just hardcoded in some values which looked reasonable to me since spawning off
a process and measuring its memory use is tricky. (Moreover, on SL, 64-bit apps
-- like sleep -- have really large vsizes.)

Powered by Google App Engine
This is Rietveld 408576698