- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Maybe cache the results of reflect.Type.MethodByName? #9386
Comments
Thanks for those numbers, I will have a look to see how to do it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See golang/go#50617
tl;dr: hugo happens to call MethodByName a lot for types with many exported methods (120).
It could be beneficial to cache the MethodByName results to avoid this pathological performance regression. Using the binary search makes big sites (https://github.com/GSA/digitalgov.gov in this case) build ~20% faster, but there is a chance that this optimization is not worthwhile in the Go stdlib itself.
With caching, it should be possible to reduce the overhead and get the speedup that is comparable to that.
Since I don't know hugo code at all, it's hard for me to give any other suggestions.
How to reproduce the behavior:
hugo
in the cloned repo root (with CPU profiling enabled)Note that there will be a few warnings related to the usages of
getenv()
, but they can be fixed rather easily.The text was updated successfully, but these errors were encountered: