Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of time is spent in go-git.v4/config.RefSpec.matchExact #275

Closed
jfontan opened this issue May 9, 2018 · 1 comment
Closed

A lot of time is spent in go-git.v4/config.RefSpec.matchExact #275

jfontan opened this issue May 9, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@jfontan
Copy link
Contributor

jfontan commented May 9, 2018

When the repository has a lot of references a lot of time is spent comparing ref names.

(pprof) top
Showing nodes accounting for 28940ms, 96.47% of 30000ms total
Dropped 11 nodes (cum <= 150ms)
Showing top 10 nodes out of 24
      flat  flat%   sum%        cum   cum%
   11820ms 39.40% 39.40%    11820ms 39.40%  runtime.memeqbody /usr/lib/go-1.9/src/runtime/asm_amd64.s
    4750ms 15.83% 55.23%    28100ms 93.67%  github.com/src-d/borges/vendor/gopkg.in/src-d/go-git%2ev4.(*Remote).addReferenceIfRefSpecMatches /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/remote.go
    3280ms 10.93% 66.17%     3280ms 10.93%  runtime.indexbytebody /usr/lib/go-1.9/src/runtime/asm_amd64.s
    1850ms  6.17% 72.33%     4220ms 14.07%  github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config.RefSpec.Src /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config/refspec.go
    1720ms  5.73% 78.07%    29960ms 99.87%  github.com/src-d/borges/vendor/gopkg.in/src-d/go-git%2ev4.(*Remote).addOrUpdateReferences /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/remote.go
    1610ms  5.37% 83.43%     5690ms 18.97%  strings.Index /usr/lib/go-1.9/src/strings/strings_amd64.go
    1270ms  4.23% 87.67%    17560ms 58.53%  github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config.RefSpec.matchExact /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config/refspec.go
    1100ms  3.67% 91.33%    23330ms 77.77%  github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config.RefSpec.Match /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config/refspec.go
     800ms  2.67% 94.00%      800ms  2.67%  strings.IndexByte /usr/lib/go-1.9/src/runtime/asm_amd64.s
     740ms  2.47% 96.47%     4060ms 13.53%  strings.Contains /usr/lib/go-1.9/src/strings/strings.go
(pprof) list RefSpec.Match
Total: 30s
ROUTINE ======================== github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config.RefSpec.Match in /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config/refspec.go
     1.10s     23.33s (flat, cum) 77.77% of Total
         .          .     73:
         .          .     74:	return spec[start:end]
         .          .     75:}
         .          .     76:
         .          .     77:// Match match the given plumbing.ReferenceName against the source.
     210ms      210ms     78:func (s RefSpec) Match(n plumbing.ReferenceName) bool {
     430ms      5.10s     79:	if !s.IsWildcard() {
     430ms     17.99s     80:		return s.matchExact(n)
         .          .     81:	}
         .          .     82:
      30ms       30ms     83:	return s.matchGlob(n)
         .          .     84:}
         .          .     85:
         .          .     86:// IsWildcard returns true if the RefSpec contains a wildcard.
         .          .     87:func (s RefSpec) IsWildcard() bool {
         .          .     88:	return strings.Contains(string(s), refSpecWildcard)
(pprof) list RefSpec.matchExact
Total: 30s
ROUTINE ======================== github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config.RefSpec.matchExact in /root/go/src/github.com/src-d/borges/vendor/gopkg.in/src-d/go-git.v4/config/refspec.go
     1.27s     17.56s (flat, cum) 58.53% of Total
         .          .     86:// IsWildcard returns true if the RefSpec contains a wildcard.
         .          .     87:func (s RefSpec) IsWildcard() bool {
         .          .     88:	return strings.Contains(string(s), refSpecWildcard)
         .          .     89:}
         .          .     90:
     210ms      210ms     91:func (s RefSpec) matchExact(n plumbing.ReferenceName) bool {
     530ms      4.75s     92:	src := s.Src()
         .          .     93:	name := n.String()
     530ms     12.60s     94:	return src == name
         .          .     95:
         .          .     96:	// return s.Src() == n.String()
         .          .     97:}
         .          .     98:
         .          .     99:func (s RefSpec) matchGlob(n plumbing.ReferenceName) bool {

Most probably the method Remote.addOrUpdateReferences is called too much.

@ajnavarro ajnavarro added the bug Something isn't working label May 9, 2018
@jfontan
Copy link
Contributor Author

jfontan commented May 17, 2018

This was addressed in src-d/go-git#833.

@jfontan jfontan closed this as completed May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants