-
Notifications
You must be signed in to change notification settings - Fork 102
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
when serving, page rendering takes longer each time #335
Comments
Huh, that sounds bad. Thanks for reporting! I'm relatively certain that this hasn't been the case in the past, though, in general we could speed up incremental builds by using the Cache API. But what you describe definitely sounds like an additional bug. If the builds take incrementally longer, we should first figure out which code paths keep repeating and why. I'd try to simplify the page as much as possible. That is, disable all other plugins and use the
These should tell us if the bibliography tag gets initialized/rendered repeatedly. If the builds take incrementally longer, I'd assume that either the rendering happens repeatedly or, if it does not, then the next step would be to time the individual steps of the render method; especially here: I'd time the individual steps to see what's consuming incrementally more time then dig down further. Before rendering the bibliography, styles and locale must be loaded. Currently, both are loaded into static memory, so on incremental builds the styles and locale files should not have to be reloaded. This should make successive builds quicker, but since that's not the case it's also worth testing this assumption. Styles are loaded into this static hash:
I'd also put breakpoints or debug output there to check whether or not the styles are being loaded for every build; I doubt this is directly related to the issue, but it would be good to know whether the plugin is completely reloaded during incremental builds or whether the styles stay in memory. |
OK I was able to profile the build like this (my first ruby!) require "jekyll"
require "ruby-prof"
result = RubyProf.profile do
options = {
"source" => './',
"destination" => './_site',
"livereload" => true,
'watch' => true,
'verbose' => true
}
Jekyll::Commands::Build.process(options)
end
stack_printer = RubyProf::CallStackPrinter.new(result)
flat_printer = RubyProf::FlatPrinter.new(result)
graph_printer = RubyProf::GraphHtmlPrinter.new(result)
File.open("_profile_stack.html", 'w') { |file| stack_printer.print(file) }
File.open("_profile_flat.txt", 'w') { |file| flat_printer.print(file) }
File.open("_profile_graph.html", 'w') { |file| graph_printer.print(file) } and so I profiled it doing a single build (144s) and a run where I edited the document so there were two builds (145s and 376s) I've attached the profiling results -- three formats, detailed in ruby-prof docs
It looks like Single build:
Double build:
I don't have more time now but thank you for your explanation, will dig into the code and try the more explicit breakpoints later if that would be helpful :) Not sure why the children would be getting called 2x as often as they should when |
Thanks! I'd run this a few more times. The incremental build-up you describe in the OP would suggest some conceptual bug that causes incremental builds to take successively longer and should become more apparent with each extra build. So far this points looks like the time is being spent parsing the bibliography. This is understandable and something that has not been optimized: for each run the bibliography is parsed again, because the BibTeX file may have changed; during builds with multiple sources the bibliography may also be parsed multiple times because the parse results are discarded in between. Both could be addressed by caching the parse results and utilizing the Cache API to detect changes on the source files. Still, just parsing the bibliography over and over again should not lead to increasingly longer build times, so there must be something else going on in addition to this. |
sorry mebs i wasn't clear! there are two separate runs,
so things in the second run (with two builds) that take 3x as long instead of 2x as long are the things that cause the time to increase. I've run it again and every time those same calls take longer :) will be tied up for another few weeks but want to help make this tool work! |
This seems to work? sneakers-the-rat@4d63f88 went from
to
not bad! I really truly do not know how to program in Ruby so this probably breaks other stuff, but it seems to at least indicate that the problem is somewhere in the way the BibTeX library is parsing things, or how often it's called, etc. |
should I PR? |
Yes, it would be great to use caching for the bibliography. Though we should use the bibliography paths as the cache key in order to support parsing multiple bibliographies. We'd also have to look into how we can clear the path if the bibliography file changes -- though we could probably just document this (i.e. you need to restart if you change the bibliography file). |
aha makes sense, still not really sure how ruby works, specifically how instances vs classes work exactly, but i can take a crack at it. I tried to mirror your cache clearing code, which seems like it checks if the paths change, but yes I don't know how to invalidate if contents of each file change, will investigate. For now it seems to be working, it does have missing references, presumably from not clearing the cache, but if i do a restart then it catches all the changes after that, so not quite sure how that's working. |
circling back around, i'm going to work on some other extensions, and wanted to know if you wanted me to work this into a PR? It still suffers from not adding new citatations that are added after |
@sneakers-the-rat sorry, I haven't been following this recently, but having looked at it quickly, I think the blocking issue in the other thread is resolved now. Would be more than happy to merge a PR opting into the cache API. |
I tried the OP's code too. Before:
After
I would be very happy if this could be integrated 👍 |
Hello! Really appreciate the plugin. I've noticed it might be that the version of Jekyll i'm using isn't supported (4.2.1) but i've noticed when i have the jekyll-scholar gem loaded and am rendering a bibliography on a page, every time that I change the source and the pages rebuild they take n times longer -- eg. if original page takes 20 seconds to build, second build takes 40, third takes 60, and so on. I've tried
--verbose
,--profile
and a bunch of other profiling methods to figure out what's taking longer but can't quite crack it -- though with--trace
it's always in the middle of some jekyll-scholar method when i call it.Any idea what might be causing the time doubling? some cache somewhere maybe? If you point me in the right direction I can try and PR since I've seen elsewhere you're mostly in maintenance mode <3
The text was updated successfully, but these errors were encountered: