Skip to content
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

stylo: Avoid using InterpolateMatrix as a fallback for matched transform function pair #18966

Merged

Conversation

@chenpighead
Copy link
Contributor

chenpighead commented Oct 20, 2017

In the current implementation, if there is any interpolation error in a matched
transform function pair, we fall-back to use InterpolateMatrix unconditionally.
However, the error could be caused by:

  1. mismatched transform function pair
  2. matched transform function pair within at least one undecomposable matrix.

Using InterpolateMatrix for case 1 makes sense, however, using InterpolateMatrix
for case 2 does not. According to the spec, we should just report error for
case 2, and let the caller do the fallback procedure. Using InterpolateMatrix
for case 2 will go through more unnecessary code path, and produce more memory
usage and calculation cost, which should be avoidable.

In this patch, we add an extra pass to check if a transform function pair have
matched operations in advance. With this information, we can easily tell whether
the interpolation error in a equal-length transform function pair is caused by
case 1 or case 2. So, we can avoid the unnecessary cost.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Bug 1399049
  • These changes do not require tests because the change is for some performance gain, and we have tests to ensure that we won't regress the existing behavior already.

This change is Reviewable

…orm function pair.

In the current implementation, if there is any interpolation error in a matched
transform function pair, we fall-back to use InterpolateMatrix unconditionally.
However, the error could be caused by:

1. mismatched transform function pair
2. matched transform function pair within at least one undecomposable matrix.

Using InterpolateMatrix for case 1 makes sense, however, using InterpolateMatrix
for case 2 does not. According to the spec, we should just report error for
case 2, and let the caller do the fallback procedure. Using InterpolateMatrix
for case 2 will go through more unnecessary code path, and produce more memory
usage and calculation cost, which should be avoidable.

In this patch, we add an extra pass to check if a transform function pair have
matched operations in advance. With this information, we can easily tell whether
the interpolation error in a equal-length transform function pair is caused by
case 1 or case 2. So, we can avoid the unnecessary cost.

Gecko bug: Bug 1399049
@highfive
Copy link

highfive commented Oct 20, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/helpers/animated_properties.mako.rs
  • @canaltinova: components/style/properties/helpers/animated_properties.mako.rs
  • @emilio: components/style/properties/helpers/animated_properties.mako.rs
@highfive
Copy link

highfive commented Oct 20, 2017

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!
@chenpighead
Copy link
Contributor Author

chenpighead commented Oct 20, 2017

This patch has been reviewed by @hiikezoe in Bug 1399049 already.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2017

📌 Commit d7a5f22 has been approved by hiro

@chenpighead
Copy link
Contributor Author

chenpighead commented Oct 20, 2017

@bors-servo r=hiikezoe
I probably should use github account to avoid unnecessary issue assignment.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2017

💡 This pull request was already approved, no need to approve it again.

  • There's another pull request that is currently being tested, blocking this pull request: #18936
@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2017

📌 Commit d7a5f22 has been approved by hiikezoe

@BorisChiou
Copy link
Contributor

BorisChiou commented Oct 20, 2017

wow. awesome @chenpighead

@bors-servo
Copy link
Contributor

bors-servo commented Oct 21, 2017

Testing commit d7a5f22 with merge 48c715c...

bors-servo added a commit that referenced this pull request Oct 21, 2017
…toring, r=hiikezoe

stylo: Avoid using InterpolateMatrix as a fallback for matched transform function pair

In the current implementation, if there is any interpolation error in a matched
transform function pair, we fall-back to use InterpolateMatrix unconditionally.
However, the error could be caused by:

1. mismatched transform function pair
2. matched transform function pair within at least one undecomposable matrix.

Using InterpolateMatrix for case 1 makes sense, however, using InterpolateMatrix
for case 2 does not. According to the spec, we should just report error for
case 2, and let the caller do the fallback procedure. Using InterpolateMatrix
for case 2 will go through more unnecessary code path, and produce more memory
usage and calculation cost, which should be avoidable.

In this patch, we add an extra pass to check if a transform function pair have
matched operations in advance. With this information, we can easily tell whether
the interpolation error in a equal-length transform function pair is caused by
case 1 or case 2. So, we can avoid the unnecessary cost.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1399049](https://bugzilla.mozilla.org/show_bug.cgi?id=1399049)
- [X] These changes do not require tests because the change is for some performance gain, and we have tests to ensure that we won't regress the existing behavior already.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18966)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 21, 2017

@bors-servo bors-servo merged commit d7a5f22 into servo:master Oct 21, 2017
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.