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

High init costs #48

Closed
moorereason opened this issue Dec 29, 2020 · 1 comment
Closed

High init costs #48

moorereason opened this issue Dec 29, 2020 · 1 comment

Comments

@moorereason
Copy link
Contributor

While testing the new init cost debugging output in go 1.16, I found that emoji has one of the higher memory init costs in Hugo's dependencies.

An an example, these are the init costs while running hugo version (which doesn't call into emoji):

$ GODEBUG=inittrace=1 go run . version 2>&1 | rg emoji
init github.com/kyokomi/emoji @15 ms, 3.9 ms clock, 783480 bytes, 3093 allocs

By deferring the emojiMap population until needed, emoji's init costs can be greatly reduced:

$ GODEBUG=inittrace=1 go run . version 2>&1 | rg emoji
init github.com/kyokomi/emoji @21 ms, 0.009 ms clock, 2824 bytes, 30 allocs

I have a branch with these changes. I can submit a PR if you're interested.

@kyokomi kyokomi mentioned this issue Dec 30, 2020
@kyokomi
Copy link
Owner

kyokomi commented Dec 30, 2020

Thanks for the issue, @moorereason.
#49 I used sync.Once to initialize the codeMap on the first use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants