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

Don't load Gemoji into memory immediately #106

Merged
merged 1 commit into from
Mar 4, 2020

Conversation

ashmaroli
Copy link
Member

Jekyll loads all plugins at a very early stage in the build process.
However, lib/emoji.rb doesn't directly reference any object initialized by the gemoji gem. The heavy-lifting is done by html-pipeline gem (which ultimately loads the gemoji library anyway, but it does so much later, after Jekyll's :post_render has been triggered).

For the curious, you may run the following script (via Bundler) to get an idea:

require 'memory_profiler'
MemoryProfiler.report { require 'gemoji' }.pretty_print(scale_bytes: true)

@ashmaroli ashmaroli requested a review from a team March 4, 2020 10:13
Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a lot of memory!

Total allocated: 7.07 MB (76405 objects)
Total retained:  1.15 MB (21140 objects)

allocated memory by file
-----------------------------------
   4.63 MB  /Users/parkr/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/gemoji-3.0.1/lib/emoji.rb
   1.29 MB  /Users/parkr/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/common.rb

@parkr
Copy link
Member

parkr commented Mar 4, 2020

Looks like the gemoji library could use some frozen_string_literal: true directives!

@mattr-
Copy link
Member

mattr- commented Mar 4, 2020

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit e9452c8 into jekyll:master Mar 4, 2020
jekyllbot added a commit that referenced this pull request Mar 4, 2020
@ashmaroli
Copy link
Member Author

Looks like the gemoji library could use some frozen_string_literal: true directives!

@parkr Took care of that months ago 😉

@ashmaroli ashmaroli deleted the no-require-gemoji branch March 4, 2020 15:47
@jekyll jekyll locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants