Skip to content

High init costs #48

Closed
Closed
@moorereason

Description

@moorereason

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions