-
Notifications
You must be signed in to change notification settings - Fork 12
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
Unpickle context only from phased
blocks
#10
base: master
Are you sure you want to change the base?
Conversation
Before this commit `utils.second_pass_render` tried to unpickle stashed context from all bits of content resulting from splitting of template by `PHASED_SECRET_DELIMITER`. Only odd bits are results of `phased` block rendering, so only those bits contain stashed context. Even bits can't contain stashed context and since they are results of first pass rendering they can be arbitrary long and even for content of sane length searching for regular expression match done in `unpickle_context` can take insanely long time. Fixed by unpickling context only from odd bits. Fixes: codysoyland#9
Hmm, interesting. Can you write a test for this, please? |
This pull request does not change output of any function and It only affects performance for cases described in #9 . So do you mean some benchmarking code, or some form of relative performance test? |
@jkuczm Something that explains what you mean with "But only odd bits are results of phased block rendering, so only those bits contain stashed context." |
In other words, if the tests pass currently it means we have either broken tests or too few tests. |
As I understand the code: In first pass rendering everything outside of In second pass rendering template is split by Current version of code in second pass rendering calls It's like adding So I don't think that fact that tests pass for current version indicates any gap in them. |
This should be merged in. I think it is completly correct and It leads to better performance (in my case page is retrieved two times faster). |
I was noticing this problem as well, and I can't think of a way to test this change without breaking the function apart and making the testing dependent on the current implementation. There doesn't appear to be any performance tests in the code right now, so this fix doesn't change the status quo. I did add a couple of comments which hopefully make the code more clear: #16 |
Function
utils.second_pass_render
tried to unpickle stashed context from all bits of content resulting from splitting of template byPHASED_SECRET_DELIMITER
.But only odd bits are results of
phased
block rendering, so only those bits contain stashed context.Even bits can't contain stashed context and since they are results of first pass rendering they can be arbitrary long and even for content of sane length, searching for regular expression match done in
utils.unpickle_context
function can take insanely long time (which is the source of problems reported in #9).Fixed by unpickling context only from odd bits.
Fixes: #9