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

Use piston_image instead of stb_image for decoding JPEGs #9790

Merged
merged 1 commit into from Mar 2, 2016

Conversation

@kaksmet
Copy link
Contributor

kaksmet commented Feb 28, 2016

The main reason stb_image was used for decoding JPEGs was the lack of progressive support in piston_image.
With version 0.7, piston_image gained support for decoding progressive JPEGs through use of the jpeg-decoder crate.

This PR removes the dependency on stb_image and instead uses piston_image 0.7 for decoding JPEGs.

Review on Reviewable

@highfive
Copy link

highfive commented Feb 28, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @SimonSapin (or someone else) soon.

@highfive
Copy link

highfive commented Feb 28, 2016

warning Warning warning

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

kaksmet commented Feb 28, 2016

Here are some performance numbers from this tool.
The images being tested are the included 4043x2641 4:2:0 baseline and progressive JPEGs.

$ ./bench.py deer.jpg
libjpeg-turbo (1.4.2)          48.55ms
stb_image (2.10)               110.04ms
jpeg-decoder (0.1.0)           149.80ms
piston-image (0.6.1)           247.39ms
go (1.6)                       193.93ms
$ ./bench.py deer_progressive.jpg
libjpeg-turbo (1.4.2)          111.15ms
stb_image (2.10)               193.93ms
jpeg-decoder (0.1.0)           301.17ms
piston-image (0.6.1)           failed
go (1.6)                       323.94ms
@frewsxcv
Copy link
Member

frewsxcv commented Feb 28, 2016

Don't those benchmarks suggest we should stick with stb_image?

@kaksmet
Copy link
Contributor Author

kaksmet commented Feb 28, 2016

@frewsxcv while it currently will be a performance regression, it will replace a C dependency with one written in Rust.

jpeg-decoder is also quite new and most work this far has gone into getting it spec-compliant, so there's still some optimization left to be done.

@frewsxcv
Copy link
Member

frewsxcv commented Feb 28, 2016

@frewsxcv while it currently will be a performance regression, it will replace a C dependency with one written in Rust.

SGTM. I'll let someone else review though.

@kaksmet kaksmet force-pushed the kaksmet:piston-jpeg branch from 5d411f7 to 79b4613 Feb 29, 2016
@kaksmet
Copy link
Contributor Author

kaksmet commented Feb 29, 2016

With version 0.1.1 of jpeg-decoder, baseline decoding went from 149.80ms to 124.82ms.

@kaksmet kaksmet force-pushed the kaksmet:piston-jpeg branch from 79b4613 to 0166c01 Feb 29, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Mar 1, 2016

The latest upstream changes (presumably #9814) made this pull request unmergeable. Please resolve the merge conflicts.

@SimonSapin
Copy link
Member

SimonSapin commented Mar 1, 2016

$ ./bench.py deer_progressive.jpg
piston-image (0.6.1)           failed

This comment in the removed code doesn’t seem to be addressed:

For JPEG images, we use stb_image because piston_image does not yet support progressive JPEG.

So this is regressing not only on performance, but also on functionality.

Beyond that, I don’t feel I can make a decision about this. r? @metajack, you’ve been working on a JPEG decoder lately, haven’t you?

@highfive highfive assigned metajack and unassigned SimonSapin Mar 1, 2016
@kaksmet
Copy link
Contributor Author

kaksmet commented Mar 1, 2016

@SimonSapin that comment is no longer relevant as piston-image 0.7 replaced it's in-tree JPEG decoder (which did not support progressive) with the jpeg-decoder crate (which does support progressive).

So the piston-image (0.6.1) in the benchmarks is pison-image's old decoder. The one that this PR would land in servo is jpeg-decoder (through piston-image 0.7).

Sorry for the confusion, the numbers you should be looking at are these:

$ ./bench.py deer.jpg
stb_image (2.10)               110.04ms
jpeg-decoder (0.1.1)           124.82ms
$ ./bench.py deer_progressive.jpg
stb_image (2.10)               193.93ms
jpeg-decoder (0.1.1)           307.42ms
@kaksmet kaksmet force-pushed the kaksmet:piston-jpeg branch from 0166c01 to 4495b9b Mar 1, 2016
@metajack
Copy link
Contributor

metajack commented Mar 1, 2016

Please squash and this is ready to merge.

I tihnk regressing performance is ok, since we expect performance to improve and it wasn't "production quality" anyway. I am working on a new GPU assisted JPEG decoder which will hopefully be faster than state of the art. If down the line we can't make Piston's decoder fast and the GPU ideas don't pan out, we can just switch to a binding of libjpeg-turbo.

+S-needs-squash


Reviewed 12 of 12 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/net_traits/image/base.rs, line 50 [r1] (raw file):
This seems slightly wrong. We don't want to allow arbitrary formats through even if Piston support them. We want to restrict to web supported formats. Adding new formats to the web accidentally is not good.

I don't think your code did this, but could you flie a bug to fix this behavior?


Comments from the review on Reviewable.io

@kaksmet kaksmet force-pushed the kaksmet:piston-jpeg branch from 4495b9b to 5c196c4 Mar 1, 2016
@kaksmet
Copy link
Contributor Author

kaksmet commented Mar 1, 2016

There is already #8406 regarding your concern about restricting supported file formats. It also seems to be fixed and should be closed?

@bors-servo
Copy link
Contributor

bors-servo commented Mar 2, 2016

The latest upstream changes (presumably #9827) made this pull request unmergeable. Please resolve the merge conflicts.

@metajack
Copy link
Contributor

metajack commented Mar 2, 2016

You're right. This was fixed. You can ignore my comment :)

As soon as you rebase I'll r+.

@jdm jdm removed the S-awaiting-review label Mar 2, 2016
Bump image to 0.7
@kaksmet kaksmet force-pushed the kaksmet:piston-jpeg branch from 5c196c4 to 8c07a1a Mar 2, 2016
@kaksmet
Copy link
Contributor Author

kaksmet commented Mar 2, 2016

Rebased

@Ms2ger
Copy link
Contributor

Ms2ger commented Mar 2, 2016

@bors-servo r=metajack

@bors-servo
Copy link
Contributor

bors-servo commented Mar 2, 2016

📌 Commit 8c07a1a has been approved by metajack

@bors-servo
Copy link
Contributor

bors-servo commented Mar 2, 2016

Testing commit 8c07a1a with merge a8c321a...

bors-servo added a commit that referenced this pull request Mar 2, 2016
Use piston_image instead of stb_image for decoding JPEGs

The main reason stb_image was used for decoding JPEGs was the lack of progressive support in piston_image.
With version 0.7, piston_image gained support for decoding progressive JPEGs through use of the [jpeg-decoder](https://crates.io/crates/jpeg-decoder) crate.

This PR removes the dependency on stb_image and instead uses piston_image 0.7 for decoding JPEGs.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9790)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 2, 2016

@bors-servo bors-servo merged commit 8c07a1a into servo:master Mar 2, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@kaksmet kaksmet deleted the kaksmet:piston-jpeg branch Mar 2, 2016
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

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