-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: large performance regression in reflect.New #16161
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
Comments
I just tested this and observed a 25% slowdown on JSON unmarshaling for one of our own systems. I can work on making a reproducer program if that would help. |
What a pity. We have a spare 4 bytes I can use for a ptrTo type offset, though I had been hoping to remove that in 1.8. I suppose for now I can add it back and try to come up with some better solution in 1.8. |
We could also consider adding
|
CL https://golang.org/cl/24400 mentions this issue. |
@rhysh if you get a chance I'd appreciate it if you could run your performance test again with tip. |
Do the JSON decoding benchmarks not capture this regression? |
I retested my benchmark with e75c899, ans I still see a 15% regression relative to Go1.6.2. Looking at a profile comparison, I see fairly substantial time increases in I've got a copy of my benchmark available here for those interested: https://play.golang.org/p/CiB34ge82s |
@potocnyj I tried that benchmark and found it too noisy to see a 15% variation. How exactly are you running it? |
@crawshaw I'm running it in batches of 10 and using https://github.com/rsc/benchstat to compare the average runtime of the benchmark with Go1.6.2 vs Go tip. Specifically, here's what my commands are:
Note that in my local environment, |
CL https://golang.org/cl/24433 mentions this issue. |
@potocnyj just a quick note on your benchmark: With GOARCH=386 it is currently 16% slower than 1.6. If I add an I'm reluctant to propose adding a method for 1.7, as while it's a small change, it's an API change. But maybe for 1.8. Alternatively at the cost of some binary size I can reduce the cost of calculating name, but it is unlikely to ever be as cheap as a boolean method. |
@crawshaw thanks for the update here - as a comparison I ran my benchmark this morning with the latest from tip ( |
CL https://golang.org/cl/24521 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
go1.7beta2: go version devel +fca9fc5 Thu Jun 16 19:45:33 2016 +0000 linux/amd64
linux/amd64
I have a program that spends most of its time marshaling and unmarshaling data that's json- and protobuf-encoded. It's been running on go1.6.x for several months (currently go1.6.2), and I upgraded it to go1.7beta2.
It's a closed-source project, and I don't currently have a small reproducer.
I expected no major performance regressions.
The program is significantly slower, with many more cycles spent in calls to
reflect.New
. Over 1/3rd of the program's execution time is spent in calls to reflect.(*rtype).ptrTo, which didn't even show up on profiles of the program under go1.6.2. Most of the time with ptrTo on the stack is in calls to RLock and RUnlock a *sync.RWMutex. The ptrTo cache appears to have been removed in February in 30f93f0.Here's a bit of a go1.6.2 profile:
And here's a bit of the profile with go1.7beta2:
The text was updated successfully, but these errors were encountered: