-
Notifications
You must be signed in to change notification settings - Fork 155
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
Faster performance when processing the clang AST #236
Conversation
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 80.82% 80.83% +0.01%
==========================================
Files 134 134
Lines 5313 5318 +5
==========================================
+ Hits 4294 4299 +5
Misses 832 832
Partials 187 187
Continue to review full report at Codecov.
|
Just for information: |
Review status: 0 of 7 files reviewed at latest revision, 1 unresolved discussion. ast/ast.go, line 225 at r1 (raw file):
I see what this PR is trying to do and its actually a very good one! You are right, this wasn't a performance problem until we introduced the SQLite3 source which is huge. This line is where you want to put the caching (rather than the other changes): var cachedRegex := map[string]*Regexp{}
func groupsFromRegex(rx, line string) map[string]string {
// ...
if _, ok := cachedRegex[fullRegexp]; !ok {
cachedRegex[fullRegexp] = regexp.MustCompile(fullRegexp)
}
re := cachedRegex[fullRegexp]
// ...
} Comments from Reviewable |
Review status: 0 of 7 files reviewed at latest revision, 2 unresolved discussions. a discussion (no related file): Comments from Reviewable |
Review status: 0 of 7 files reviewed at latest revision, 2 unresolved discussions. a discussion (no related file): Previously, elliotchance (Elliot Chance) wrote…
Ok. ast/ast.go, line 225 at r1 (raw file): Previously, elliotchance (Elliot Chance) wrote…
That the reason - Why I don`t create a full design. Your design with cache is awesome. Comments from Reviewable |
Reviewed 1 of 7 files at r1, 1 of 6 files at r2. Comments from Reviewable |
I use 2 ways for change the transpiling perfomance:
Changes inside
ast
.Before: for execute
parseBuiltinType
we compile the Regex inside functiongroupsFromRegex
. So, if we have N-elements ofBuiltinType
- we create N-elements of Regex.After : Now, we create only one Regex for
BuiltinType
. So, we save the time to compile the Regex.That changes created not for all AST elements
Change inside
main.go
, seeconvertLinesToNodes
. We can save the time, because at the begin we know "Amount of nodes is not more amount of Lines".Results:
go install ; time $GOPATH/bin/c2go transpile -o /tmp/for.go ./tests/for.c
Before:
After
Run
go test -tags=integration ./...
:Before:
After:
Little bit faster at 6...10%.
Please clarify your point of view - Is it interesting for project?
This change is