Skip to content

Instantly share code, notes, and snippets.

Eric Rahm EricRahm

Block or report user

Report or block EricRahm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View about_memory_parser.py
import json
import collections
import sys
import operator
from pprint import pprint
def path_total(data, path):
totals = collections.defaultdict(int)
totals_heap = collections.defaultdict(int)
@EricRahm
EricRahm / gist:a5b96df4583a163bf809
Last active Aug 29, 2015
On device memory profiling
View gist:a5b96df4583a163bf809

Figuring out available memory on a device

adb shell cat /proc/meminfo

  • MemTotal tells you how much device memory is available outside of drivers/kernel.
  • MemFree tells you how much memory is currently available, checking this after booting should give you a rough guesstimate of what our max is.

To simulate what would happen in a low-memory situation you can adb shell kill <pid> each b2g process but b2g, (Nuwa), Homescreen (use b2g-ps to get a b2g process listing). Unfortunately Homescreen just comes back (it can be LMK'd though, so add it's USS to the MemFree total to get a better idea of an ideal MemFree value).

Get an overview of b2g application memory usage

@EricRahm
EricRahm / gist:dae275b3dbed2d13b65a
Last active Aug 29, 2015
AWSY - real hardware vs virtualized
View gist:dae275b3dbed2d13b65a

On an 8 core, 32GB machine

  • 2015/03/04 Nightly build
  • 16 iterations, 8 at a time 2 loops
  • numbers in KiB
   iteration,       Start,    Start+30,         Max,      Max+30,  MaxForceGC,         End,      End+30,  EndForceGC
           0,       99971,       87024,      392673,      377293,      345905,      311185,      203429,      171741
           1,      100135,       86956,      390233,      381165,      348737,      328053,      182673,      171661
@EricRahm
EricRahm / gist:a89ba84044d8b2d506fb
Last active Aug 29, 2015
AWSY - 1 iteration vs 5
View gist:a89ba84044d8b2d506fb

Memory usage at each checkpoint iteration against 16 runs of the same build

  • measurements in KiB
0
       MaxMemory:      387121,      386285,      395233,      383053,      392673
MaxMemorySettled:      378761,      377333,      381805,      376645,      377293
MaxMemoryForceGC:      342881,      343821,      348389,      345189,      345905
       EndMemory:      312305,      323221,      328185,      325237,      311185
EndMemorySettled:      164317,      196825,      178641,      201841,      203429
View gist:06bfc119764aa18cef1c

extension

auth/nsAuthGSSAPI.cpp

// Generate proper GSSAPI error messages from the major and
// minor status codes.
void
LogGssError(OM_uint32 maj_stat, OM_uint32 min_stat, const char *prefix)
{
    OM_uint32 new_stat;
    OM_uint32 msg_ctx = 0;
@EricRahm
EricRahm / gist:d18098cdf93ffe7a8445
Last active Aug 29, 2015
PR_LOG level mappings
View gist:d18098cdf93ffe7a8445

Currently:

typedef enum PRLogModuleLevel {
    PR_LOG_NONE = 0,                /* nothing */
    PR_LOG_ALWAYS = 1,              /* always printed */ <---- lies, damned lies
    PR_LOG_ERROR = 2,               /* error messages */
    PR_LOG_WARNING = 3,             /* warning messages */
    PR_LOG_DEBUG = 4,               /* debug messages */

    PR_LOG_NOTICE = PR_LOG_DEBUG,   /* notice messages */ this one's weird
@EricRahm
EricRahm / gist:3a85cb04d4d3791e8666
Last active Aug 29, 2015
PRLogModuleInfo replacement
View gist:3a85cb04d4d3791e8666

An attempt to get rid of lazy log instantiation boilerplate

#define LAZY_LOG_GETTER(fnx, name) \
    LogModule* fnx() { static LogModule* module = LogModule::CreateModule(name); return module; }

LAZY_LOG_GETTER(GetFooLog, "foo");

// ...

MOZ_LOG(GetFooLog(), LogLevel::Debug, ("Debugging the foo!"));
@EricRahm
EricRahm / gist:0068cd58c33f9c0694cc
Last active Aug 29, 2015
Reporting MediaRawData
View gist:0068cd58c33f9c0694cc

Reporting for MediaRawData:

Option 1: Report it in nsDocument::DocAddSizeOfExcludingThis (nsINode) HTMLMediaElement -> MediaSource -> SourceBuffer -> TrackBufferManager -> MediaRawData Pro: this should work Con: It would be rather generic under mDOMElementNodesSize

njn suggested expanding the struct to specify HTMLMediaElement specific stuff

@EricRahm
EricRahm / async_reporter.cpp
Created Aug 14, 2015
Example async memory reporting
View async_reporter.cpp
// pseudo-pythonish-cpp, whatever
total_reporters = len(reporters)
do_memory_reports:
// this is on the main thread
for r in reporters:
main_thread_dispatch(new DoReportEvent(r));
start_timer(on_report_done);
@EricRahm
EricRahm / memory_reporter_state.md
Last active Oct 5, 2015
Memory Reporter State
View memory_reporter_state.md

Currently two focuses:

  • GetReportsState: roughly the interprocess state, keeps track of which subprocesses need to callled / are running. This is only in the parent process.
  • CollectReportsState: intraprocess state, used in runnable, keeps track of which CollectReports calls are pending. This is in all processes and created in GetReportsForThisProcessExtended
  struct GetReportsState                                                                                               
  {
    uint32_t                             mGeneration;                                                                  
    bool                                 mAnonymize;                                                                   
You can’t perform that action at this time.