Browse Source

added gc major timings to profiler output

Nicolas Cannasse 3 years ago
parent
commit
25fe0430ba
2 changed files with 10 additions and 5 deletions
  1. 6 3
      other/profiler/ProfileGen.hx
  2. 4 2
      src/profile.c

+ 6 - 3
other/profiler/ProfileGen.hx

@@ -1,6 +1,6 @@
 
 class StackElement {
-	static var UID = 1;
+	static var UID = 0;
 	public var id : Int;
 	public var desc : String;
 	public var file : String;
@@ -129,6 +129,7 @@ class ProfileGen {
 		if( f.readString(4) != "PROF" ) throw "Invalid profiler file";
 		var version = f.readInt32();
 		var sampleCount = f.readInt32();
+		var gcMajor = new StackElement("GC Major");
 		var rootElt = new StackElement("(root)");
 		var hthreads = new Map();
 		var threads = [];
@@ -148,7 +149,7 @@ class ProfileGen {
 			}
 			var msgId = f.readInt32();
 			if( msgId < 0 ) {
-				var count = msgId & 0x7FFFFFFF;
+				var count = msgId & 0x3FFFFFFF;
 				var stack = [];
 				for( i in 0...count ) {
 					var file = f.readInt32();
@@ -175,10 +176,12 @@ class ProfileGen {
 					}
 					stack[i] = elt;
 				}
+				if( msgId & 0x40000000 != 0 )
+					stack.unshift(gcMajor);
 				if( tcur.curFrame.samples.length == 100000 ) {
 					tcur.curFrame = new Frame();
 					tcur.curFrame.startTime = time;
-					tcur.frames.push(tcur.curFrame);			
+					tcur.frames.push(tcur.curFrame);
 				}
 				tcur.curFrame.samples.push({ time : time, thread : tid, stack : stack });
 			} else {

+ 4 - 2
src/profile.c

@@ -201,6 +201,8 @@ static void read_thread_data( thread_handle *t ) {
 #endif
 	int eventId = count | 0x80000000;
 	double time = hl_sys_time();
+	struct { int count; bool stop; } *gc = hl_gc_threads_info();
+	if( gc->stop ) eventId |= 0x40000000;
 	record_data(&time,sizeof(double));
 	record_data(&t->tid,sizeof(int));
 	record_data(&eventId,sizeof(int));
@@ -321,7 +323,7 @@ static void profile_dump() {
 		fwrite(&tid,1,4,f);
 		fwrite(&eventId,1,4,f);
 		if( eventId < 0 ) {
-			int count = eventId & 0x7FFFFFFF;
+			int count = eventId & 0x3FFFFFFF;
 			read_profile_data(&r,data.stackOut,sizeof(void*)*count);
 			for(i=0;i<count;i++) {
 				uchar outStr[256];
@@ -361,7 +363,7 @@ static void profile_dump() {
 		if( !read_profile_data(&r,NULL, sizeof(double) + sizeof(int)) ) break;
 		read_profile_data(&r,&eventId,sizeof(int));
 		if( eventId < 0 ) {
-			int count = eventId & 0x7FFFFFFF;
+			int count = eventId & 0x3FFFFFFF;
 			read_profile_data(&r,data.stackOut,sizeof(void*)*count);
 			for(i=0;i<count;i++) {
 				int *debug_addr = NULL;