Commit af61bc1
authored
Replace go-git with native git for faster code generation
The code generator was bottlenecked by `go-git` a pure-Go git
implementation that is significantly slower than native git for
large repositories like aws-sdk-go-v2. `EnsureRepo` was called
3 times per build, each time fetching all remote tags and
performing a full `worktree` checkout through `go-git'`s slow
object traversal. This made `make build-controller` take 2/3/5+
minutes even with a cached repository.
Replaced `go-git` with native `exec.Command("git", ...)` calls,
resolved the SDK version before fetching to enable single tag
fetch instead of fetching all tags, and added a local tag
existence check to skip the network round trip entirely when
the tag is already cached. The full ECR controller build now
completes in under 10 seconds on repeated runs. Removed go-git
and ~10 transitive dependencies from the module.
Warm (tag cached, already checked out):
| Command | go-git | native git | Speedup |
|--------------------------------|---------|------------|-----------|
| `ack-generate apis ecr` | 62.3s | 2.3s | **27x** |
| `ack-generate controller ecr` | 108.0s | 0.4s | **270x** |
Cold (tag not cached, must fetch):
| Command | go-git | native git | Speedup |
|--------------------------------|---------|------------|-----------|
| `ack-generate apis ecr` | 95.1s | 46.2s | **2.1x** |
| `ack-generate controller ecr` | 55.2s | 36.2s | **1.5x** |
The real optimization isn't the checkout speed (2.3x) - it's skipping
the network fetch entirely with HasTag() when the tag already exists
locally, which turns a 30-50s operation into a no op.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.13 files changed
Lines changed: 213 additions & 254 deletions
File tree
- cmd/ack-generate/command
- pkg
- apiv2
- generate/ack
- model/multiversion
- sdk
- util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
| 124 | + | |
114 | 125 | | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
| 130 | + | |
118 | 131 | | |
| 132 | + | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
| |||
132 | 146 | | |
133 | 147 | | |
134 | 148 | | |
| 149 | + | |
| 150 | + | |
135 | 151 | | |
136 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| 65 | + | |
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
| |||
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| 76 | + | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| 83 | + | |
| 84 | + | |
74 | 85 | | |
75 | 86 | | |
76 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
74 | 83 | | |
| 84 | + | |
| 85 | + | |
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
78 | 89 | | |
| 90 | + | |
79 | 91 | | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| 96 | + | |
83 | 97 | | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
| |||
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| 114 | + | |
| 115 | + | |
99 | 116 | | |
100 | 117 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
46 | | - | |
47 | | - | |
48 | 42 | | |
49 | 43 | | |
50 | | - | |
51 | 44 | | |
52 | 45 | | |
53 | 46 | | |
54 | | - | |
55 | | - | |
56 | 47 | | |
57 | 48 | | |
58 | 49 | | |
59 | 50 | | |
60 | 51 | | |
61 | | - | |
62 | 52 | | |
63 | 53 | | |
64 | | - | |
| 54 | + | |
65 | 55 | | |
66 | 56 | | |
67 | 57 | | |
68 | 58 | | |
69 | | - | |
70 | 59 | | |
71 | 60 | | |
72 | 61 | | |
73 | | - | |
74 | 62 | | |
75 | 63 | | |
76 | 64 | | |
77 | 65 | | |
78 | 66 | | |
79 | | - | |
80 | 67 | | |
81 | 68 | | |
82 | 69 | | |
83 | 70 | | |
84 | 71 | | |
85 | | - | |
86 | 72 | | |
87 | | - | |
88 | 73 | | |
89 | 74 | | |
90 | | - | |
91 | 75 | | |
92 | 76 | | |
93 | | - | |
94 | 77 | | |
95 | | - | |
| 78 | + | |
96 | 79 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
101 | 84 | | |
102 | | - | |
103 | 85 | | |
104 | 86 | | |
105 | 87 | | |
106 | | - | |
107 | 88 | | |
108 | 89 | | |
109 | 90 | | |
| |||
119 | 100 | | |
120 | 101 | | |
121 | 102 | | |
| 103 | + | |
122 | 104 | | |
123 | 105 | | |
0 commit comments