diff options
| author | Russ Cox <rsc@golang.org> | 2012-02-08 10:33:54 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-02-08 10:33:54 -0500 |
| commit | 5b93fc9da67d59159e8c30494136c9761e350c1f (patch) | |
| tree | 774246edfb5de099e0793fd559c95eacf49a31a7 /src/pkg/runtime/proc.c | |
| parent | fff732ea2c4d3cb449c4383a6957ff80ca75c70a (diff) | |
| download | go-5b93fc9da67d59159e8c30494136c9761e350c1f.tar.xz | |
runtime, pprof: add profiling of thread creation
Same idea as heap profile: how did each thread get created?
Low memory (256 bytes per OS thread), high reward for
programs that suddenly have many threads running.
Fixes #1477.
R=golang-dev, r, dvyukov
CC=golang-dev
https://golang.org/cl/5639059
Diffstat (limited to 'src/pkg/runtime/proc.c')
| -rw-r--r-- | src/pkg/runtime/proc.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 5bb690aaa8..e008be9677 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -324,13 +324,6 @@ runtime·idlegoroutine(void) static void mcommoninit(M *m) { - // Add to runtime·allm so garbage collector doesn't free m - // when it is just in a register or thread-local storage. - m->alllink = runtime·allm; - // runtime·Cgocalls() iterates over allm w/o schedlock, - // so we need to publish it safely. - runtime·atomicstorep(&runtime·allm, m); - m->id = runtime·sched.mcount++; m->fastrand = 0x49f6428aUL + m->id + runtime·cputicks(); m->stackalloc = runtime·malloc(sizeof(*m->stackalloc)); @@ -338,6 +331,15 @@ mcommoninit(M *m) if(m->mcache == nil) m->mcache = runtime·allocmcache(); + + runtime·callers(1, m->createstack, nelem(m->createstack)); + + // Add to runtime·allm so garbage collector doesn't free m + // when it is just in a register or thread-local storage. + m->alllink = runtime·allm; + // runtime·Cgocalls() iterates over allm w/o schedlock, + // so we need to publish it safely. + runtime·atomicstorep(&runtime·allm, m); } // Try to increment mcpu. Report whether succeeded. |
