Skip to content

Commit 542a187

Browse files
committed
stats
1 parent 59443b3 commit 542a187

File tree

6 files changed

+69087
-1
lines changed

6 files changed

+69087
-1
lines changed

Slides.md

+136-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ We want to highlight a few changes and how they affect everyday Go development:
4242

4343
* move to **Go modules** for dependency management
4444
* introduction of **generic types**
45-
* **standard library** additions: [`hash/maphash`](https://pkg.go.dev/hash/maphash) (1.14), [`testing/Cleanup`](https://pkg.go.dev/testing#T.Cleanup), [`time/tzdata`](https://pkg.go.dev/time/tzdata) (1.15), [`embed`](https://pkg.go.dev/embed) (1.16), [`testing/SetEnv`](https://pkg.go.dev/testing#T.Cleanup), [`debug/buildinfo`](https://pkg.go.dev/debug/buildinfo) (1.18), [`net/netip`](https://pkg.go.dev/net/netip) (1.18)
45+
* **standard library** additions:
46+
[`hash/maphash`](https://pkg.go.dev/hash/maphash) (1.14),
47+
[`testing/Cleanup`](https://pkg.go.dev/testing#T.Cleanup),
48+
[`time/tzdata`](https://pkg.go.dev/time/tzdata) (1.15),
49+
[`embed`](https://pkg.go.dev/embed) (1.16),
50+
[`testing/SetEnv`](https://pkg.go.dev/testing#T.Setenv),
51+
[`debug/buildinfo`](https://pkg.go.dev/debug/buildinfo) (1.18),
52+
[`net/netip`](https://pkg.go.dev/net/netip) (1.18)
4653
* **tools** evolution (e.g. fuzz testing)
4754

4855
As well as use cases, users and **ecosystem** changes.
@@ -88,6 +95,133 @@ code age, extensions (move from [C to Go](https://go.dev/doc/go1.5#c) in 1.5):
8895

8996
![Various plots generated with git-of-theseus](static/theseus/stats_combined.png)
9097

98+
## More stats
99+
100+
Using [mergestat]() for git repo analysis:
101+
102+
```
103+
$ mergestat -f tsv -r . "SELECT commits.hash, stats.* FROM commits, stats('', commits.hash)" > commts.tsv
104+
```
105+
106+
Drop into pydata:
107+
108+
> Commits per year
109+
110+
```
111+
In [37]: df.groupby(df.date.dt.year)["hash"].nunique()
112+
Out[37]:
113+
date
114+
1972 1
115+
1974 1
116+
1988 2
117+
2008 1396
118+
2009 3116
119+
2010 2501
120+
2011 3994
121+
2012 3754
122+
2013 3378
123+
2014 3343
124+
2015 4784
125+
2016 4803
126+
2017 4258
127+
2018 3887
128+
2019 3392
129+
2020 3989
130+
2021 4825
131+
2022 1508
132+
Name: hash, dtype: int64
133+
```
134+
135+
> Top 5 files changed per year (2018-2022)
136+
137+
```python
138+
>>> df.groupby(df.date.dt.year)["dir"].value_counts().sort_values().to_csv("dirfreq.csv")
139+
```
140+
141+
```csv
142+
2018,src/cmd/compile/internal/ssa,854
143+
2018,src/cmd/vendor/golang.org/x/sys/unix,881
144+
2018,src/syscall,914
145+
2018,src/cmd/compile/internal/gc,1174
146+
2018,src/runtime,2258
147+
148+
2019,src/cmd/compile/internal/ssa,753
149+
2019,src/cmd/compile/internal/gc,877
150+
2019,src/cmd/go/testdata/script,1078
151+
2019,src/vendor/golang.org/x/sys/unix,1106
152+
2019,src/runtime,2727
153+
154+
2020,src/cmd/compile/internal/ssa,1475
155+
2020,src/cmd/vendor/golang.org/x/sys/unix,1883
156+
2020,src/cmd/go/testdata/script,2199
157+
2020,src/cmd/compile/internal/gc,2488
158+
2020,src/runtime,2835
159+
160+
2021,src/cmd/compile/internal/types2,2085
161+
2021,src/cmd/go/testdata/script,2094
162+
2021,src/go/types,2159
163+
2021,src/cmd/vendor/golang.org/x/sys/unix,2476
164+
2021,src/runtime,5202
165+
166+
2022,src/cmd/compile/internal/types2,516
167+
2022,src/go/types,530
168+
2022,src/go/types/testdata/fixedbugs,646
169+
2022,test/typeparam,663
170+
2022,src/runtime,1143
171+
```
172+
173+
Most changes (dir):
174+
175+
```
176+
$ cat changes.tsv | tail -20 | column -t
177+
src/cmd/go/internal/modload 52171 26710 78881
178+
src/cmd/compile/internal/ir 60114 23182 83296
179+
src/cmd/oldlink/internal/ld 27955 59698 87653
180+
src/cmd/vendor/golang.org/x/arch/x86/x86asm 44218 48632 92850
181+
src/cmd/compile/internal/typecheck 75263 23292 98555
182+
src/crypto/tls/testdata 56391 55537 111928
183+
src/cmd/compile/internal/ssa/gen 66771 56927 123698
184+
src/cmd/compile/internal/noder 106658 24330 130988
185+
src/cmd/go/testdata/script 124204 14609 138813
186+
src/cmd/link/internal/ld 79214 60428 139642
187+
src/go/types 102641 54215 156856
188+
src/cmd/compile/internal/types2 147363 44516 191879
189+
src/syscall 120857 83241 204098
190+
doc 45680 201068 246748
191+
src/cmd/compile/internal/gc 100028 284737 384765
192+
src/runtime 279826 136985 416811
193+
src/time/tzdata 229072 213100 442172
194+
src/vendor/golang.org/x/sys/unix 408978 445375 854353
195+
src/cmd/vendor/golang.org/x/sys/unix 411688 540942 952630
196+
src/cmd/compile/internal/ssa 736274 990519 1726793
197+
```
198+
199+
A few other packages as comparison:
200+
201+
```
202+
$ cat changes.tsv | grep -E "(src/io|src/net|src/os)" | sort -nrk4,4 | head -20 | column -t
203+
src/net/http 28520 11507 40027
204+
src/net 20462 10633 31095
205+
src/os 18546 6748 25294
206+
src/net/netip 9808 318 10126
207+
src/io/fs 6054 507 6561
208+
src/os/exec 3966 2352 6318
209+
src/os/signal 3603 1204 4807
210+
src/net/http/httputil 3231 549 3780
211+
src/net/url 2609 919 3528
212+
src/io/ioutil 1020 1247 2267
213+
src/os/user 1273 660 1933
214+
src/io 1206 386 1592
215+
src/net/http/cgi 1045 546 1591
216+
src/net/http/pprof 1121 250 1371
217+
src/net/mail 986 118 1104
218+
src/net/http/httptest 862 200 1062
219+
src/net/http/fcgi 695 189 884
220+
src/net/smtp 752 71 823
221+
src/net/http/internal/ascii 780 0 780
222+
src/net/textproto 509 268 777
223+
```
224+
91225
## Generics
92226

93227
Or: [parametric polymorphism](https://en.wikipedia.org/wiki/Parametric_polymorphism)
@@ -533,3 +667,4 @@ router.Handle("/assets/", http.FileServer(http.FS(assets)))
533667
```
534668

535669
Individual files can be directly embedded as `[]byte` or `string`.
670+

hacking/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Hacking
2+
3+
Trying to identify active files in Go source tree.
4+
5+
* most touched files, in the past years
6+
* average number of files changed per commit
7+
* average number of commits per day
8+
9+
```
10+
$ mergestat -f ndjson -r . "select commits.author_when, commits.hash, files.path from commits, files('', commits.hash)" | jq -rc .
11+
```
12+
13+
Or tsv (120kL/s)
14+
15+
```
16+
$ mergestat -f tsv-noheader -r . "select commits.author_when, commits.hash, files.path from commits, files('', commits.hash)"
17+
```
18+
19+
Stats:
20+
21+
```
22+
$ mergestat -f tsv -r . "SELECT commits.hash, stats.* FROM commits, stats('', commits.hash)" > commts.tsv
23+
```

0 commit comments

Comments
 (0)