Skip to content

Instantly share code, notes, and snippets.

View DanielMorsing's full-sized avatar

Daniel Morsing DanielMorsing

View GitHub Profile
@DanielMorsing
DanielMorsing / stacktrace.diff
Last active June 16, 2019 12:20
Patch that adds stack growth events to the trace viewer
diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go
index f39a397d0d..de8348e996 100644
--- a/src/cmd/trace/trace.go
+++ b/src/cmd/trace/trace.go
@@ -739,6 +739,8 @@ func generateTrace(params *traceParams, consumer traceConsumer) error {
ctx.emitInstant(ev, "task start", "user event")
case trace.EvUserTaskEnd:
ctx.emitInstant(ev, "task end", "user event")
+ case trace.EvGoCopyStack:
+ ctx.emitInstant(ev, "copystack", "")
diff --git a/src/net/http/server.go b/src/net/http/server.go
index 57e1b5dacb..31c8352ca2 100644
--- a/src/net/http/server.go
+++ b/src/net/http/server.go
@@ -22,6 +22,7 @@ import (
"os"
"path"
"runtime"
+ "runtime/causalprof"
"strconv"
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"runtime/causalprof"
"sync"
"math/rand"
)
@DanielMorsing
DanielMorsing / foo.go
Created January 31, 2016 18:07
the program
package main
import (
"runtime/causalprof"
"net/http"
"bufio"
"os"
"math/rand"
"fmt"
"sync/atomic"
0x4d183d /home/daniel/go/src/math/rand/rand.go:206
2542898460
5% 2324966363ns -8.57%
30% 2326460354ns -8.51%
35% 2277724044ns -10.4%
45% 2314790374ns -8.97%
50% 2243652563ns -11.8%
95% 1974680705ns -22.3%

Keybase proof

I hereby claim:

  • I am danielmorsing on github.
  • I am dmorsing (https://keybase.io/dmorsing) on keybase.
  • I have a public key whose fingerprint is 85A4 D9E4 546F 39F5 7891 92E4 C9C6 BA30 0461 FEBE

To claim this, I am signing this object:

<!--{
Navbar: "Home",
}-->
/* other stuff after this */
/* should be matched by "<!--.*-->" */
package main
import (
"net/http"
"path"
)
var fshandler = http.FileServer(http.Dir("assets/"))
func scrubber(w http.ResponseWriter, r *http.Request) {
<!DOCTYPE HTML>
<html>
{{template "header"}} //this i want executed before runtime
<body>
{{template "navbar" "Blog"}} //same with this
</body>
//all this should only be executed at runtime
MAGIC ESCAPE THINGY
{{.title}}
[daniel@morslaptop ~]$ mkdir foo && cd foo
[daniel@morslaptop foo]$ bash -c 'cd .. && rm -rf foo'
[daniel@morslaptop foo]$ man open
man: can't change directory to '': No such file or directory
man: command exited with status 255: (cd && LESS=-ix8RmPm Manual page open(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page open(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=open(1) less -s)