Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2018-07-06 21:22:43 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-07-06 21:22:43 +0300
commita150803f6022fb46473515b57fb8e1738786cf84 (patch)
tree6f3be7526c17b002e702682f5533060ff5787eec
parent449133f786e6df001c64e20f30ea7ab13e05ba8e (diff)
Remove unnecessary commit size calculations
-rw-r--r--changelogs/unreleased/fix-commit-size-nil-panic.yml5
-rw-r--r--internal/service/commit/commits_helper.go14
-rw-r--r--internal/service/commit/server.go1
3 files changed, 8 insertions, 12 deletions
diff --git a/changelogs/unreleased/fix-commit-size-nil-panic.yml b/changelogs/unreleased/fix-commit-size-nil-panic.yml
new file mode 100644
index 000000000..4b46a87bb
--- /dev/null
+++ b/changelogs/unreleased/fix-commit-size-nil-panic.yml
@@ -0,0 +1,5 @@
+---
+title: Remove unnecessary commit size calculations
+merge_request: 791
+author:
+type: fixed
diff --git a/internal/service/commit/commits_helper.go b/internal/service/commit/commits_helper.go
index e6771a9d8..ae1f0071f 100644
--- a/internal/service/commit/commits_helper.go
+++ b/internal/service/commit/commits_helper.go
@@ -14,6 +14,8 @@ type commitsSender interface {
Send([]*pb.GitCommit) error
}
+const commitsPerChunk = 20
+
func sendCommits(ctx context.Context, sender commitsSender, repo *pb.Repository, revisionRange []string, paths []string, extraArgs ...string) error {
cmd, err := log.GitLogCommand(ctx, repo, revisionRange, paths, extraArgs...)
if err != nil {
@@ -26,18 +28,15 @@ func sendCommits(ctx context.Context, sender commitsSender, repo *pb.Repository,
}
var commits []*pb.GitCommit
- commitsSize := 0
for logParser.Parse() {
commit := logParser.Commit()
- commitsSize += commitSize(commit)
- if commitsSize >= maxMsgSize {
+ if len(commits) >= commitsPerChunk {
if err := sender.Send(commits); err != nil {
return err
}
commits = nil
- commitsSize = 0
}
commits = append(commits, commit)
@@ -59,10 +58,3 @@ func sendCommits(ctx context.Context, sender commitsSender, repo *pb.Repository,
return nil
}
-
-func commitSize(commit *pb.GitCommit) int {
- return len(commit.Id) + len(commit.Subject) + len(commit.Body) +
- len(commit.Author.Name) + len(commit.Author.Email) + len(commit.Committer.Name) + len(commit.Committer.Email) +
- 8 + 8 + // Author and Committer timestamps are int64
- len(commit.ParentIds)*40
-}
diff --git a/internal/service/commit/server.go b/internal/service/commit/server.go
index 7607d6f48..eb2f3046d 100644
--- a/internal/service/commit/server.go
+++ b/internal/service/commit/server.go
@@ -13,7 +13,6 @@ type server struct {
var (
defaultBranchName = ref.DefaultBranchName
- maxMsgSize = 1024 * 128 // 128 KiB
)
// NewServer creates a new instance of a grpc CommitServiceServer