Skip to content

Commit

Permalink
fix: fix gittar oom
Browse files Browse the repository at this point in the history
  • Loading branch information
jing-zhi committed Feb 28, 2024
1 parent a89edd2 commit e3415b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/tools/gittar/ai/cr/impl/cr_mr/mr.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (r *mrReviewer) CodeReview(i18n i18n.Translator, lang i18n.LanguageCodes, a
wg := limit_sync_group.NewSemaphore(MaxDiffFileNum) // parallel is 5
var mu sync.Mutex

wg.Add(len(changedFiles))
for _, file := range changedFiles {
wg.Add(1)
fileOrder = append(fileOrder, file.GetFileName())
go func(file models.FileCodeReviewer) {
defer wg.Done()
Expand Down
8 changes: 3 additions & 5 deletions pkg/limit_sync_group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ func NewSemaphore(maxSize int) *limitSyncGroup {
}
func (s *limitSyncGroup) Add(delta int) {
s.wg.Add(delta)
go func() {
for i := 0; i < delta; i++ {
s.c <- struct{}{}
}
}()
for i := 0; i < delta; i++ {
s.c <- struct{}{}
}
}
func (s *limitSyncGroup) Done() {
<-s.c
Expand Down

0 comments on commit e3415b6

Please sign in to comment.