зеркало из https://github.com/mozilla/pjs.git
bug 113738 Cost of malloc into trace-malloc log. r=blythe, sr=brendan
This commit is contained in:
Родитель
a6d576842a
Коммит
8fd8cb15ca
|
@ -245,6 +245,26 @@ int showHelp(void)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
** ticks2msec
|
||||
**
|
||||
** Convert platform specific ticks to msec time
|
||||
** Returns 0 on success.
|
||||
*/
|
||||
PRUint32 ticks2msec(tmreader* aReader, PRUint32 aTicks)
|
||||
{
|
||||
PRUint32 retval = 0;
|
||||
PRUint64 bigone = LL_INIT(0, 1000);
|
||||
PRUint64 tmp64;
|
||||
|
||||
LL_UI2L(tmp64, aTicks);
|
||||
LL_MUL(bigone, bigone, tmp64);
|
||||
LL_UI2L(tmp64, aReader->ticksPerSec);
|
||||
LL_DIV(bigone, bigone, tmp64);
|
||||
LL_L2UI(retval, bigone);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
** initOptions
|
||||
**
|
||||
|
@ -2222,7 +2242,7 @@ void tmEventHandler(tmreader* aReader, tmevent* aEvent)
|
|||
{
|
||||
eventType = TM_EVENT_FREE;
|
||||
}
|
||||
trackEvent(aEvent->u.alloc.interval, eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize);
|
||||
trackEvent(ticks2msec(aReader, aEvent->u.alloc.interval), eventType, callsite, aEvent->u.alloc.ptr, aEvent->u.alloc.size, oldcallsite, oldptr, oldsize);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#endif
|
||||
#include "prlog.h"
|
||||
#include "plhash.h"
|
||||
#include "prnetdb.h"
|
||||
#include "nsTraceMalloc.h"
|
||||
#include "tmreader.h"
|
||||
|
||||
|
@ -169,6 +170,8 @@ static int get_tmevent(FILE *fp, tmevent *event)
|
|||
case TM_EVENT_FREE:
|
||||
if (!get_uint32(fp, &event->u.alloc.interval))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.cost))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.ptr))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.size))
|
||||
|
@ -176,11 +179,24 @@ static int get_tmevent(FILE *fp, tmevent *event)
|
|||
event->u.alloc.oldserial = 0;
|
||||
event->u.alloc.oldptr = 0;
|
||||
event->u.alloc.oldsize = 0;
|
||||
#if defined(DEBUG_dp)
|
||||
if (c == TM_EVENT_MALLOC)
|
||||
printf("%d malloc %d 0x%p\n", event->u.alloc.cost,
|
||||
event->u.alloc.size, event->u.alloc.ptr);
|
||||
else if (c == TM_EVENT_CALLOC)
|
||||
printf("%d calloc %d 0x%p\n", event->u.alloc.cost,
|
||||
event->u.alloc.size, event->u.alloc.ptr);
|
||||
else
|
||||
printf("%d free %d 0x%p\n", event->u.alloc.cost,
|
||||
event->u.alloc.size, event->u.alloc.ptr);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case TM_EVENT_REALLOC:
|
||||
if (!get_uint32(fp, &event->u.alloc.interval))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.cost))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.ptr))
|
||||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.size))
|
||||
|
@ -191,6 +207,10 @@ static int get_tmevent(FILE *fp, tmevent *event)
|
|||
return 0;
|
||||
if (!get_uint32(fp, &event->u.alloc.oldsize))
|
||||
return 0;
|
||||
#if defined(DEBUG_dp)
|
||||
printf("%d realloc %d 0x%p %d\n", event->u.alloc.cost,
|
||||
event->u.alloc.size, event->u.alloc.ptr, event->u.alloc.oldsize);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case TM_EVENT_STATS:
|
||||
|
@ -391,6 +411,16 @@ int tmreader_eventloop(tmreader *tmr, const char *filename,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Read in ticks per second. Used to convert platform specific intervals to time values */
|
||||
if (read(fileno(fp), &tmr->ticksPerSec, sizeof tmr->ticksPerSec) != sizeof tmr->ticksPerSec) {
|
||||
fprintf(stderr, "%s: Cannot read ticksPerSec. Log file read error.\n",
|
||||
tmr->program);
|
||||
return 0;
|
||||
}
|
||||
tmr->ticksPerSec = PR_ntohl(tmr->ticksPerSec);
|
||||
#ifdef DEBUG_dp
|
||||
printf("DEBUG: ticks per sec = %d\n", tmr->ticksPerSec);
|
||||
#endif
|
||||
while (get_tmevent(fp, &event)) {
|
||||
switch (event.type) {
|
||||
case TM_EVENT_LIBRARY: {
|
||||
|
|
|
@ -65,12 +65,13 @@ struct tmevent {
|
|||
uint32 offset;
|
||||
} site;
|
||||
struct {
|
||||
uint32 interval;
|
||||
uint32 interval; /* in ticks */
|
||||
uint32 ptr;
|
||||
uint32 size;
|
||||
uint32 oldserial;
|
||||
uint32 oldptr;
|
||||
uint32 oldsize;
|
||||
uint32 cost; /* in ticks */
|
||||
} alloc;
|
||||
struct {
|
||||
nsTMStats tmstats;
|
||||
|
@ -155,6 +156,7 @@ struct tmreader {
|
|||
PLHashTable *methods;
|
||||
PLHashTable *callsites;
|
||||
tmcallsite calltree_root;
|
||||
uint32 ticksPerSec;
|
||||
};
|
||||
|
||||
typedef void (*tmeventhandler)(tmreader *tmr, tmevent *event);
|
||||
|
|
Загрузка…
Ссылка в новой задаче