Skip to content

Instantly share code, notes, and snippets.

View EricRahm's full-sized avatar

Eric Rahm EricRahm

View GitHub Profile
@EricRahm
EricRahm / about_memory_parser.py
Created January 29, 2015 23:00
about memory parser
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 August 29, 2015 14:16
On device memory profiling

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 August 29, 2015 14:16
AWSY - real hardware vs virtualized

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 August 29, 2015 14:16
AWSY - 1 iteration vs 5

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
@EricRahm
EricRahm / gist:06bfc119764aa18cef1c
Last active August 29, 2015 14:20
PR_LOG cleanup

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 August 29, 2015 14:21
PR_LOG level mappings

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 August 29, 2015 14:22
PRLogModuleInfo replacement

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 August 29, 2015 14:26
Reporting MediaRawData

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 August 14, 2015 00:40
Example async memory reporting
// 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 October 5, 2015 19:21
Memory Reporter State

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;