Skip to content

Conditional re-renders#220

Merged
d00rman merged 4 commits intowikimedia:masterfrom
gwicke:rerender
Mar 26, 2015
Merged

Conditional re-renders#220
d00rman merged 4 commits intowikimedia:masterfrom
gwicke:rerender

Conversation

@gwicke
Copy link
Member

@gwicke gwicke commented Mar 26, 2015

gwicke added 2 commits March 25, 2015 11:27
- Handle exceptions throwing falsy values better
- Preserve full internal error objects & log them
We should allow modules to maintain their own metrics, so expose the metrics
instance publicly rather than hiding it away in the _priv object.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 86.37% when pulling 4ee8c1d on gwicke:rerender into 50247be on wikimedia:master.

@gwicke
Copy link
Member Author

gwicke commented Mar 26, 2015

/cc @eevans @d00rman

This patch processes a no-cache update request for a parsoid content revision
by letting Parsoid parse the page as usual. However, instead of blindly
storing the new render, we now compare the content with the previous render's
content & don't store a new revision if nothing changed. The hope is that this
will reduce our storage requirements from template updates significantly,
assuming that many template-triggered re-renders don't actually change the
content. A statsd counter is set up to track the effectiveness of this
optimization.

Since Parsoid currently emits non-deterministic about attributes (see link to
task), we need to perform some slightly hacky HTML normalization to avoid
marking all HTML pages as differing. This hack should be removed once the
Parsoid bug is fixed.

I also used the opportunity to clean up a few things in the parsoid module:

- Move the method setup to the mod constructor. This makes those methods
  available to the module itself without going through routing. Also removed
  the factory function in favor of simple currying / bind.

- Create a new uuid directly in generateAndSave instead of passing it in from
  all users.

The tests have been updated to use a simpler and thus more reliable set of
pages to test changing vs. unchanging re-renders. A timestamp parser function
is used to force updates in one of the pages.

Bug: https://phabricator.wikimedia.org/T93779
@gwicke gwicke force-pushed the rerender branch 2 times, most recently from 2ca4854 to 02aa098 Compare March 26, 2015 05:43
@gwicke gwicke changed the title Don't store a new render if the content did not change Conditional re-renders Mar 26, 2015
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) to 86.32% when pulling 02aa098 on gwicke:rerender into 50247be on wikimedia:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) to 86.32% when pulling cd2ef25 on gwicke:rerender into 50247be on wikimedia:master.

mods/parsoid.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to stick to the spec, we should actually ignore If-Unmodified-Since when the date is invalid.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's what the try/catch is about.

This patch cleans up the code paths in the parsoid module further by combining
the revision fetching in getFormat with the one needed for the equality check
as introduced in the previous patch. This also makes it easier to add
if-unmodified-since support. On precondition failure, status 412 is returned
and no parsing or other content is returned.

Bug: https://phabricator.wikimedia.org/T93777
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with you on not exposing pagebundle, it's used only internally in this module anyway.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.16%) to 86.42% when pulling e907cb5 on gwicke:rerender into 50247be on wikimedia:master.

d00rman pushed a commit that referenced this pull request Mar 26, 2015
@d00rman d00rman merged commit 3eedbd1 into wikimedia:master Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants