Skip to content

Instantly share code, notes, and snippets.

View EricRahm's full-sized avatar

Eric Rahm EricRahm

View GitHub Profile
#!/usr/bin/env python
import json
import jsonschema
import socket
import uuid
import time
from thclient import (TreeherderClient, TreeherderJobCollection, TreeherderArtifactCollection)
# These would come from a config
CLIENT_ID = 'awsy-local' # TODO(ER): Load from a config
@EricRahm
EricRahm / example.cpp
Created October 6, 2015 21:10
lambdas, oh my
LocallyDefinedMemoryReporter::CollectReports(...) {
// grab refs for stuff to shove in the lambda
nsCOMPtr<nsIHandleReportCallback> handleReport = aHandleReport;
nsCOMPtr<nsISupports> data = aData;
// this is defined elsewhere, we want it to hit the callback when it's refs drop to 0
nsRefPtr<MediaDecoder::ResourceSizes> resourceSizes = new MediaDecoder::ResourceSizes(MediaMemoryTracker::MallocSizeOf);
nsCOMPtr<nsIRunnable> callback = NS_NewRunnableFunction([handleReport, data, resourceSizes] () {
// NOTE: referencing resourcesSizes causes a cycle, so it's ref count will never go to 0
// so my goal is to not do that, preferably this function would be something like:
@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;                                                                   
@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 / 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 / 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: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: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: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: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