-
Notifications
You must be signed in to change notification settings - Fork 99
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
Indexing: clean up ctags parser wrapper #708
Conversation
|
||
parser := lp.parsers[typ] | ||
recv := make(chan parseResult, 1) | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified here by using a new goroutine and channel per parse request. It looked totally fine in benchmarks, but maybe this is bad practice. Any thoughts?
return resp.entries, resp.err | ||
case <-deadline.C: | ||
// Error out since ctags hanging is a sign something bad is happening. | ||
return nil, fmt.Errorf("ctags timedout after %s parsing %s", parseTimeout, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to make this a hard error, in contrast to before where if require_ctags
was not set, we attempted to restart the ctags process and move to the next document. It felt better to keep this simple, especially since we always enable require_ctags
by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
ctags/json.go
Outdated
func (lp *CTagsParser) Close() { | ||
for _, parser := range lp.parsers { | ||
parser.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old implementation protected from calling lp.p.Close twice. Not sure if that is needed given Close likely can be called twice. Just checking :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding: because of how parser.Close()
is implemented, it is okay to call twice. I just tested this by adding an extra call to parser.Close()
during indexing and it was fine. Also, we do try to structure things so that parser.Close()
should ever only be called once.
ctags/json.go
Outdated
go func() { | ||
entry, err := parser.Parse(name, content) | ||
recv <- parseResult{entries: entry, err: err} | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the overhead of a new goroutine is likely fine given we know ctags is already the bottleneck. I'd be interested to know if it pops up in profiles now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I didn't see any difference in job latency or in the CPU profiles
Thanks for the review! |
This change cleans up the Go ctags parser wrapper as a follow-up to #702. Specific changes:
lockedParser
and rename it toCTagsParser
Relates to https://github.com/sourcegraph/sourcegraph/issues/58112