Skip to content

Commit 8a3e1c1

Browse files
changed pause request parameter name to sleep
1 parent 34c2434 commit 8a3e1c1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ front and back end for experimenting with Go's garbage collection tuning knobs (
99
The app uses the go-git library and git repos (of your choice) that you have cloned to your computer. The app does not fetch them from github.
1010

1111
For example,
12-
to create a steady state for the garbage collector, you could read the repo for Ruby on Rails into memory 50 times with a 2 second pause in between each read.
12+
to create a steady state for the garbage collector, you could read the repo for Ruby on Rails into memory 50 times with a 2 second sleep in between each read.
1313

14-
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/rails", "repeat":"50", "pause":"2"}' -X POST http://localhost:8000/git_repo
14+
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/rails", "repeat":"50", "sleep":"2"}' -X POST http://localhost:8000/git_repo
1515

1616
Then, if you want to, create a transitory spike in memory, you could open another terminal window and read youtube-dl into memory once.
1717

18-
<p>curl -H 'Content-Type: application/json' -d '{"path":"/path/to/youtube-dl", "repeat":"1", "pause":"1"}' -X POST http://localhost:8000/git_repo</p>
18+
<p>curl -H 'Content-Type: application/json' -d '{"path":"/path/to/youtube-dl", "repeat":"1", "sleep":"1"}' -X POST http://localhost:8000/git_repo</p>
1919

2020
## Understanding GOMEMLIMIT and GOGC
2121
You can find tips for setting GOGC and GOMEMLIMIT at Go's garbage collection guide https://tip.golang.org/doc/gc-guide
@@ -45,17 +45,17 @@ In this example, you can see there was a heap spike at approximately 3:16:45. In
4545

4646
This example was run using ruby on rails to establish a steady state
4747

48-
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rails", "repeat":"50", "pause":"2"}' -X POST http://localhost:8000/git_repo
48+
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rails", "repeat":"50", "sleep":"2"}' -X POST http://localhost:8000/git_repo
4949

5050
and then using the Rust repository to create a heap spike
5151

52-
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rust", "repeat":"3", "pause":"1"}' -X POST http://localhost:8000/git_repo
52+
curl -H 'Content-Type: application/json' -d '{"path":"/Users/mm/rust", "repeat":"3", "sleep":"1"}' -X POST http://localhost:8000/git_repo
5353

5454
## git repositories as data source
5555

5656
You will have to clone a few git repositories of varying sizes to create a data source for GC Knobs. The far right column (NextGC range in GC_Knobs) gives the range for the NextGC value during a steady state created by running the following request for each repository.
5757

58-
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/repository", "repeat":"30", "pause":"1"}' -X POST http://localhost:8000/git_repo
58+
curl -H 'Content-Type: application/json' -d '{"path":"/path/to/repository", "repeat":"30", "sleep":"1"}' -X POST http://localhost:8000/git_repo
5959

6060
| Repository | # of commits | Objects/Megabytes (clone/download) | NextGC range in GC_Knobs |
6161
| -------- | ------- | ------- | ---- |

gitrepo.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
1717
type GitRepo struct {
1818
Path string `json:"path"`
1919
Repeat string `json:"repeat"`
20-
Pause string `json:"pause`
20+
Sleep string `json:"sleep`
2121
}
2222
type ResponseId struct {
2323
Id int `json:"id"`
@@ -48,8 +48,8 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
4848

4949
startTime := time.Now()
5050
repeat, err := strconv.Atoi(gr.Repeat)
51-
pause, err := strconv.Atoi(gr.Pause)
52-
_, _, _ = getLog(gr.Path, repeat, pause)
51+
sleep, err := strconv.Atoi(gr.Sleep)
52+
_, _, _ = getLog(gr.Path, repeat, sleep)
5353

5454
stopTime := time.Now()
5555
executionTime := stopTime.Sub(startTime)
@@ -58,21 +58,21 @@ func GitRepo(w http.ResponseWriter, req *http.Request) {
5858
type response struct {
5959
Path string `json:"path"`
6060
Repeat int `json:"repeat"`
61-
Pause int `json:"pause"`
61+
Sleep int `json:"sleep"`
6262
ExecutionTime time.Duration `json:"execution_time (nanoseconds)"`
6363
}
6464

6565
res := response{
6666
Path: gr.Path,
6767
Repeat: repeat,
68-
Pause: pause,
68+
Sleep: sleep,
6969
ExecutionTime: execTime,
7070
}
7171

7272
json.NewEncoder(w).Encode(res)
7373

7474
}
75-
func getLog(path string, repeat int, pause int) (string, int, int) {
75+
func getLog(path string, repeat int, sleep int) (string, int, int) {
7676

7777
if repeat == 0 {
7878
repeat = 1
@@ -102,11 +102,11 @@ func getLog(path string, repeat int, pause int) (string, int, int) {
102102

103103
} else {
104104

105-
time.Sleep(time.Duration(pause) * time.Second)
105+
time.Sleep(time.Duration(sleep) * time.Second)
106106
}
107107

108108
}
109109

110-
return path, repeat, pause
110+
return path, repeat, sleep
111111

112112
}

0 commit comments

Comments
 (0)