Commit 9540ce5
refs: write packed_refs file using stdio
We write each line of a new packed-refs file individually
using a write() syscall (and sometimes 2, if the ref is
peeled). Since each line is only about 50-100 bytes long,
this creates a lot of system call overhead.
We can instead open a stdio handle around our descriptor and
use fprintf to write to it. The extra buffering is not a
problem for us, because nobody will read our new packed-refs
file until we call commit_lock_file (by which point we have
flushed everything).
On a pathological repository with 8.5 million refs, this
dropped the time to run `git pack-refs` from 20s to 6s.
Signed-off-by: Jeff King <[email protected]>
Reviewed-by: Michael Haggerty <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 0c72b98 commit 9540ce5
3 files changed
+33
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1395 | 1395 | | |
1396 | 1396 | | |
1397 | 1397 | | |
| 1398 | + | |
| 1399 | + | |
1398 | 1400 | | |
1399 | 1401 | | |
1400 | 1402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2191 | 2191 | | |
2192 | 2192 | | |
2193 | 2193 | | |
2194 | | - | |
| 2194 | + | |
2195 | 2195 | | |
2196 | 2196 | | |
2197 | | - | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
2209 | | - | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
2213 | 2200 | | |
2214 | 2201 | | |
2215 | 2202 | | |
2216 | 2203 | | |
2217 | 2204 | | |
2218 | 2205 | | |
2219 | 2206 | | |
2220 | | - | |
2221 | 2207 | | |
2222 | 2208 | | |
2223 | 2209 | | |
2224 | 2210 | | |
2225 | 2211 | | |
2226 | | - | |
| 2212 | + | |
2227 | 2213 | | |
2228 | 2214 | | |
2229 | 2215 | | |
| |||
2259 | 2245 | | |
2260 | 2246 | | |
2261 | 2247 | | |
| 2248 | + | |
2262 | 2249 | | |
2263 | 2250 | | |
2264 | 2251 | | |
2265 | | - | |
2266 | | - | |
2267 | 2252 | | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
2268 | 2258 | | |
2269 | | - | |
2270 | | - | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
2271 | 2264 | | |
2272 | 2265 | | |
2273 | 2266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
0 commit comments