Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

add option use-git-cache which makes single git log ... call #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

klandergren
Copy link

This diff does two things:

  1. aligns path_cache behavior in determinator.rb so that both formatted and raw
    calls to last_modified_time are read from the path_cache

  2. adds option use-git-cache which improves render performance by reading the
    entire git log once (instead of 1:1 for each file)

More information available in #85

I did not test extensively but did verify that bundle exec rake spec passed. bundle exec rake rubocop reported an issue with Style/OptionalBooleanParameter which I did not think worth changing existing code to accommodate.

This diff does two things:

1. aligns path_cache behavior in determinator.rb so that both formatted and raw
calls to last_modified_time are read from the path_cache

2. adds option `use-git-cache` which improves render performance by reading the
entire git log once (instead of 1:1 for each file)
`item.path` returns the absolute path to a file, whereas other instantiations
of `Determinator`, like in `tag.rb`, use a relative path. by using a relative
path in both places we increase the likelihood of cache hits.
Copy link

@khemarato khemarato left a comment

Choose a reason for hiding this comment

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

Love this PR! I'll be forking this soon as I take a stab at implementing a solution to #90 :) Thanks so much for your contribution! 🙏 [EDIT/PS: I'm not a maintainer of this repo, just a passerby.]

@@ -3,49 +3,47 @@
module Jekyll
module LastModifiedAt
class Determinator
attr_reader :site_source, :page_path
@repo_cache = {}
@path_cache = {}

Choose a reason for hiding this comment

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

This is actually a last modified time cache keyed on paths. @last_mod_cache perhaps?

raise Errno::ENOENT, "#{absolute_path_to_article} does not exist!" unless File.exist? absolute_path_to_article

Time.at(last_modified_at_unix.to_i)
self.class.path_cache[page_path] = Time.at(last_modified_at_unix.to_i)
self.class.path_cache[page_path]

Choose a reason for hiding this comment

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

ruby returns the last value by default, so this last line is redundant, no?

@@ -8,6 +8,7 @@ class Git
def initialize(site_source)
@site_source = site_source
@is_git_repo = nil
@lcd_cache = {}

Choose a reason for hiding this comment

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

What does "lcd" stand for here? As opposed to what other kind of cache?

Copy link

Choose a reason for hiding this comment

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

I reckon it stands for "last commit date", per the next hunk

}
end

Jekyll::Hooks.register :site, :after_reset do |site|
Copy link

@khemarato khemarato Nov 14, 2021

Choose a reason for hiding this comment

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

I personally didn't find this hook very helpful: it triggers a cache clear every file change while I'm developing, slowing my incremental builds and with no benefit, as uncommitted changes don't show up in git log

@gjtorikian
Copy link
Owner

👋 Unfortunately, my GitHub notifications for this repository was oddly turned off. I take my responsibility to accepting patches seriously; however, I am just one person, with a very busy life off of GitHub.com! I'm going to close this PR because I like to keep my TODO list scoped and reasonable. This does not mean I will not accept this patch! Rather, it's a way of me asking you if you're still using this gem, and whether you want this PR merged. Just comment back and I'll prioritize it. I assume silence means I can keep it closed. Thanks!

this was an automated copy-paste

@gjtorikian gjtorikian closed this Jun 4, 2024
@khemarato
Copy link

I'm still using this PR

@gjtorikian gjtorikian reopened this Jun 4, 2024
@gjtorikian gjtorikian added the TODO label Jun 4, 2024
@khemarato
Copy link

Sorry, should have mentioned: I built on this PR in #91 - If you just merge 91, it should come with this functionality... up to you how to handle it 😊

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

Successfully merging this pull request may close these issues.

4 participants