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

Optimize by caching webmention data into memory #105

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

ashmaroli
Copy link
Contributor

Results in massive performance gains by bypassing repeated parsing of YAML files 🎉

@ashmaroli
Copy link
Contributor Author

@nhoizey Will you be able to test your site against this branch to test if there are any performance improvements (without loss of existing renders from this plugin) in real-world sites..?
Thanks 😃

@aarongustafson
Copy link
Owner

Wow, that cut things in half with my test site. Will try on a local build of my site momentarily.

@aarongustafson
Copy link
Owner

On my site it cut build time from ~1000s to ~200s. What a huge difference from such a small change!

#
# Returns nothing.
def self.dump_yaml(file, data = {})
@webmention_data_cache[file] = data
File.open(file, "wb") { |f| f.puts YAML.dump(data) }
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a way to async this operation so it doesn’t block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which of the two operations is the blocker..?
Either ways, :dump_yaml is called just 3-4 times in a build, so it shouldn't cause any noticeable bottlenecks..

Copy link
Owner

Choose a reason for hiding this comment

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

I was figuring the disk write might do some blocking. But maybe it doesn’t.

@aarongustafson aarongustafson merged commit 4f83c33 into aarongustafson:master Sep 14, 2018
@ashmaroli ashmaroli deleted the cache-data-memory branch September 17, 2018 02:28
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

Successfully merging this pull request may close these issues.

2 participants