Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
git-bug
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
MichaelMure
git-bug
Commits
8ea04df8
Unverified
Commit
8ea04df8
authored
6 years ago
by
Michael Muré
Browse files
Options
Downloads
Patches
Plain Diff
serial_format_research: check the repo size before and after git gc
parent
6efb0eba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
misc/serial_format_research/main.go
+60
-9
60 additions, 9 deletions
misc/serial_format_research/main.go
repository/git.go
+12
-0
12 additions, 0 deletions
repository/git.go
with
72 additions
and
9 deletions
misc/serial_format_research/main.go
+
60
−
9
View file @
8ea04df8
...
...
@@ -6,11 +6,13 @@ import (
"log"
"os"
"path"
"path/filepath"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/misc/random_bugs"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util"
"github.com/dustin/go-humanize"
"github.com/ugorji/go/codec"
)
...
...
@@ -22,9 +24,7 @@ type testCase struct {
}
func
main
()
{
packs
:=
random_bugs
.
GenerateRandomOperationPacks
(
10
,
5
)
repo
:=
createRepo
(
false
)
packs
:=
random_bugs
.
GenerateRandomOperationPacks
(
1000
,
5
)
testCases
:=
[]
testCase
{
{
...
...
@@ -49,8 +49,15 @@ func main() {
fmt
.
Println
()
fmt
.
Println
(
testcase
.
name
)
total
:=
int64
(
0
)
for
_
,
opp
:=
range
packs
{
repo
:=
createRepo
(
false
)
sizeEmpty
,
err
:=
dirSize
(
repo
.
GetPath
())
if
err
!=
nil
{
panic
(
err
)
}
// total := int64(0)
for
i
,
opp
:=
range
packs
{
rawSize
,
hash
,
err
:=
testcase
.
writer
(
opp
,
repo
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -58,13 +65,46 @@ func main() {
size
:=
blobSize
(
hash
,
repo
)
total
+=
size
//
total += size
if
i
<
10
{
ratio
:=
float32
(
size
)
/
float32
(
rawSize
)
*
100.0
fmt
.
Printf
(
"raw: %v, git: %v, ratio: %v%%
\n
"
,
rawSize
,
size
,
ratio
)
}
}
fmt
.
Printf
(
"total: %v
\n
"
,
total
)
fmt
.
Println
(
"..."
)
sizeFilled
,
err
:=
dirSize
(
repo
.
GetPath
())
if
err
!=
nil
{
panic
(
err
)
}
err
=
repo
.
GC
()
if
err
!=
nil
{
panic
(
err
)
}
sizePacked
,
err
:=
dirSize
(
repo
.
GetPath
())
if
err
!=
nil
{
panic
(
err
)
}
err
=
repo
.
GCAggressive
()
if
err
!=
nil
{
panic
(
err
)
}
sizeAggressive
,
err
:=
dirSize
(
repo
.
GetPath
())
if
err
!=
nil
{
panic
(
err
)
}
fmt
.
Printf
(
"Unpacked: %v
\n
"
,
humanize
.
Bytes
(
uint64
(
sizeFilled
-
sizeEmpty
)))
fmt
.
Printf
(
"GC packed: %v
\n
"
,
humanize
.
Bytes
(
uint64
(
sizePacked
-
sizeEmpty
)))
fmt
.
Printf
(
"Packing diff: %v
\n
"
,
sizePacked
-
sizeFilled
)
fmt
.
Printf
(
"GC packed aggressive: %v
\n
"
,
humanize
.
Bytes
(
uint64
(
sizeAggressive
-
sizeEmpty
)))
fmt
.
Printf
(
"Packing diff: %v
\n
"
,
sizeAggressive
-
sizePacked
)
}
}
...
...
@@ -118,6 +158,17 @@ func blobSize(hash util.Hash, repo *repository.GitRepo) int64 {
return
fi
.
Size
()
}
func
dirSize
(
path
string
)
(
int64
,
error
)
{
var
size
int64
err
:=
filepath
.
Walk
(
path
,
func
(
_
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
!
info
.
IsDir
()
{
size
+=
info
.
Size
()
}
return
err
})
return
size
,
err
}
func
writeGOB
(
opp
*
bug
.
OperationPack
,
repo
repository
.
Repo
)
(
int
,
util
.
Hash
,
error
)
{
data
,
err
:=
opp
.
Serialize
()
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
repository/git.go
+
12
−
0
View file @
8ea04df8
...
...
@@ -388,3 +388,15 @@ func (repo *GitRepo) CreateWitness(time util.LamportTime) error {
func
(
repo
*
GitRepo
)
EditWitness
(
time
util
.
LamportTime
)
error
{
return
repo
.
editClock
.
Witness
(
time
)
}
func
(
repo
*
GitRepo
)
GC
()
error
{
_
,
err
:=
repo
.
runGitCommand
(
"gc"
)
return
err
}
func
(
repo
*
GitRepo
)
GCAggressive
()
error
{
_
,
err
:=
repo
.
runGitCommand
(
"gc"
,
"--aggressive"
)
return
err
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment