This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Comments in makefiles follow the same form as comments in bash. | |
# Makefiles need to be named "Makefile" or "makefile". | |
# In makefiles, variables are declared in the following manner (the entire | |
# string after the equals and up to but excluding the newline is the | |
# content of the variable) | |
# | |
# Note: there are other ways to declare variables that are not explored in this | |
# tutorial. | |
TARGET = my_cc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go build thingy | |
# thingy | |
src/thingy/main.go:6: imported and not used: "mypkg" | |
src/thingy/main.go:14: undefined: mypkg | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build ignore | |
// malloc test for false sharing | |
package main | |
import ( | |
"flag" | |
"runtime" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "http" | |
func main() { | |
http.Handle("/", http.FileServer(http.Dir("/tmp"))) | |
http.ListenAndServe(":8080", nil) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ hg blame runtime.c | grep runtime·rnd | |
6707: runtime·rnd(uint32 n, uint32 m) | |
$ hg log -r 6707 | |
changeset: 6707:629c065d3679 | |
user: Russ Cox <[email protected]> | |
date: Thu Nov 04 14:00:19 2010 -0400 | |
summary: runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
done := false | |
go func() { | |
for !done { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./malloctest --proc=2 --iters=100 --prof 2>out2.prof | |
$ go tool pprof malloctest out2.prof | |
out2.prof: header size >= 2**16 | |
go tool pprof: exit status 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ptr2uintptr(ptr []byte) uintptr { | |
return uintptr(unsafe.Pointer(ptr)) // cannot convert ptr (type []byte) to type unsafe.Pointer | |
/* | |
if bp, e := strconv.ParseInt(fmt.Sprintf("%p", ptr), 0, 32); e != nil { | |
log.Fatal(e) | |
} else { | |
return uintptr(bp) | |
} | |
panic("unreachable") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
areece@areece-laptop:~/coding/gomalloc$ ./malloccheck --checkcache=true --procs=1 | |
Malloc check ran with 1 procs for 1000000 iters of size 16 | |
Cache line shared 0 (0.00%) times | |
Cache was reused 993536 (99.35%) times | |
areece@areece-laptop:~/coding/gomalloc$ ./malloccheck --checkcache=true --procs=2 | |
Malloc check ran with 2 procs for 1000000 iters of size 16 | |
Cache line shared 128186 (12.82%) times | |
Cache was reused 859014 (85.90%) times | |
areece@areece-laptop:~/coding/gomalloc$ ./malloccheck --checkcache=true --procs=3 | |
Malloc check ran with 3 procs for 1000000 iters of size 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/pkg/runtime/malloc.goc Mon Apr 09 15:39:59 2012 -0400 | |
+++ b/src/pkg/runtime/malloc.goc Mon Apr 23 17:37:10 2012 -0400 | |
@@ -25,7 +25,7 @@ | |
// Small objects are allocated from the per-thread cache's free lists. | |
// Large objects (> 32 kB) are allocated straight from the heap. | |
void* | |
-runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed) | |
+INVALID_FUNC_DECLruntime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed) | |
{ | |
int32 sizeclass, rate; |
OlderNewer