Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Performance degradation #203

@icambridge

Description

@icambridge

So if I have a long running process I end up with what I would consider serious performance degradation. The following code when the process originally starts takes ms however as the process goes on the takes longer and longer no matter the size of the repository. I've seen it literally taking 10s of minutes on really small git repositories.

func (gc *GitRepository) FetchFiles() (*FileList, error) {

	if len(gc.files) > 0 {
		return &FileList{gc.files}, nil
	}

	log.Infof("Fetching files for %s", gc.name)
	ref, err := gc.repository.Head()
	if err != nil {
		return nil, err
	}

	// ... retrieving the commit object
	commit, err := gc.repository.Commit(ref.Hash())

	if err != nil {
		return nil, err
	}
	tree, err := commit.Tree()

	if err != nil {
		return nil, err
	}
	fileIt := tree.Files()

	defer fileIt.Close()
	repoFiles := map[string]File{}
	for {
		fo, err := fileIt.Next()

		if err != nil {
			break
		}
		repoFile := GitFile{
			fo:  fo,
		}
		repoFiles[fo.Name] = repoFile
	}
	gc.files = repoFiles
	log.Infof("Finished fetching files for %s", gc.name)
	return &FileList{repoFiles}, nil
}

Also may as well use this issue for the memory performance issues with this library and commits as can be seen on https://github.com/icambridge/go-git-example with symfony/symfony taking up a GB of RAM just to get the commits.

Overall I have a 8 core 16GB server processing 140 repositories an hour running out of memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions