-
Notifications
You must be signed in to change notification settings - Fork 207
MRG: Only rebuild necessary parts #448
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
Conversation
Does this need conf.py to have a change or does it just work? |
It should just work |
On sphinx-gallery:
Checking matplotlib; update in about 30 minutes 😉 |
In matplotlib, after running
Note that there are lots of *.new files in that directory, so not entirely clear what didn't work... |
On sklearn sphinx tells me that it's seeing about 60 changed files (instead of hundreds) and the second build runs in a few seconds. |
I wonder if the above issue is something funky about the cases:
Note that |
Codecov Report
@@ Coverage Diff @@
## master #448 +/- ##
==========================================
+ Coverage 96.15% 96.21% +0.06%
==========================================
Files 29 29
Lines 2418 2564 +146
==========================================
+ Hits 2325 2467 +142
- Misses 93 97 +4
Continue to review full report at Codecov.
|
@jklymak I can't replicate that error in building the
I don't know why you see any other files since the case does not match. Are you on Windows? Maybe there is some file-case-insensitivity problem...? Is it possible you are on some broken Looking at the code, I'm not sure how it's possible you see this error. Can you paste the full traceback? Is it in
Regardless of where Nonetheless can you try the latest commit? |
Okay I'm thinking this is a file case sensitivity problem. There is I can make the code not produce an error, but the output will still not be correct. |
Commit pushed to avoid the error and emit a warning. |
Ready for review/merge from my end. @choldgraf feel free to have a look if you have time. |
I'm on a mac, so there are definite case issues ( |
Works now, so long as I don't fail on warning for matplotlib. OTOH: This PR:
Master:
So, this doesn't particularly speed up incremental building (8s has to be in the noise compared to other stuff I'm doing on my machine)... |
Maybe your
I can confirm this behavior makes sense by:
You can clearly see only five Moreover, if instead of changing the introductory paragraph or title (which SG turns into a tooltip in the Did you change some other example? If so, maybe it has worse consequences and we can track down why. Can you see if you can replicate what I see by just changing |
... and as a further diagnostic, you can look at e.g. |
EDIT: This is all updated, my appologies if you have been following along.... I just updated to sphinx 1.8.4. This is on a Mac. OK, thats bizarre: Just changing
If I change
and If I change
and it takes ~200s
So.... Something funky about the If I go back to Master:
So this PR definitely speeds things up, quite a bit.... |
The only weird thing about
|
Confirmed, removing the
So, why do those png files trigger rebuilding 2264 source files if anything else in that directory is modified? |
No idea, but it sounds like this PR is at least working then |
@larsoner Its certainly much faster 👍 Thanks a lot for coming up with the correct solution! OTOH, I am still not sure why it takes over 30 s to re-write all the I'll note that the |
Yes agreed, but I think that's a Sphinx issue. In principle it's only supposed to write for files that are added or changed. |
OK, if I run
If I run it on sphinx-gallery the second time...
and then it re-writes all the html files. Since there is only 46 of them, its pretty fast, but for matplotlib, there are 4000 of them, so it takes a while. A jaunt through Feel free to open a new issue if this is the incorrect place to discuss this. This PR removes a big performance drop, but there are others that seem fixable... |
Removing that check in sphinx drops the matplotlib compile time from 71 s to 24 s. So the question is why does the |
At least in that case, it's probably because you changed the
|
... and if I comment out |
What do you mean I changed the conf file? I don’t touch that between builds. When you run make do you get 46 files added? If so then the buildfile is still not registering properly somehow. Edit: run make on Sphinx-gallery. If you run make on matplotlib it says 4000 odd files. |
Ahh sorry I misunderstood what you did. I'll take a look to see what's causing the rebuild and see if I can address it here. I have a sneaking suspicion it's our "Sphinx hack" |
@jklymak I think I have narrowed it down to these to
I'm guessing that it's because Sphinx can't tell if these config values have changed or not, so decides to re-write everything. With those two lines as they are in
If I comment out those two lines and do
@jklymak can you confirm? If so, what we could do is allow these entries to be strings and do some |
I can confirm the above, except for the fact that my computer is slower than yours 😉 |
This works fine. Set to 'info', and MPL build works out of the box. OTOH, this seems a bit hacky. I'm still a little confused about what is happening; I'm on APFS, which is case-aware, but probably case insensitive because I migrated from HFS+ on this machine. It seems that the code to make the "*.new" files might be able to figure out that "Subplot" should be "subplot"? It would be a strange library that had case-conflicts in their module names like that. |
It seems like the right behavior to A sphinx build on a case insensitive file system with a lib that requires case sensitivity in its submodules seems like it must break |
Just to be clear, I'm on a mac... 😉 |
OK, well maybe this is a different bug:
I tracked this down to a few cases where |
Yes I think |
sphinx_gallery/utils.py
Outdated
assert method in ('move', 'copy') | ||
if fname_old is None: | ||
assert fname_new.endswith('.new') | ||
fname_old = fname_new[:-4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nitpick, in my experience this is a bit more dangerous than just doing os.path.splitext(fname_new)[0]
...it seems trivial but I've been bitten by it before when I change code in the future
this looks really nice to me in general - and to be clear, it sounds like this doesn't require any new behavior on the part of the user, yeah? If that's the case, once we're sure that @jklymak is happy with the current behavior and since tests are passing, then I'm +1 on merge. (I added a small nitpick comment but it shouldn't block on merging) |
Seems great to me! |
will merge tomorrow unless anybody speaks up otherwise! :-) |
Correct.
Done! |
had another appveyor config conflict...I think I resolved it properly, let's see if tests are happy then I'll merge if so! |
ok tests are happy so I'm 🚢 ing it |
Thanks a lot @larsoner - this will really speed things up! |
This writes a few files with a
.new
extension and replaces the old one only if necessary (e.g.,.py
,.rst
files) to avoid Sphinx rebuilding them. Most of the added lines are new tests adapted from #466.@NicolasHug @jklymak can you see if it works for you?
Closes #449
Closes #446
Closes #400
Closes #395
Closes #394