-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Super slow open+resize+save on big Jpeg with Mono #94
Comments
Hmmm... Something amiss here. 946ms on my laptop. Could you do me a favor and tell me what the results of Mono supports NET4.6 as I recall, would it be possible to bump to that and get back to us? I'll double check we're not doing something daft and releasing our code in debug mode also. |
I wonder which part is slow, what is the output of the following code. Stopwatch sw1 = new Stopwatch();
sw1.Start();
string tmpFilePath = Path.GetTempPath() + "x-imagesharp" + Path.GetExtension(filePath);
using (FileStream stream = File.OpenRead(filePath))
using (FileStream output = File.OpenWrite(tmpFilePath))
{
Image image = new Image(stream);
sw1.Stop();
Console.WriteLine("Image sharp read: " + sw1.ElapsedMilliseconds);
sw1.Restart();
image.Resize(200, 300);
sw1.Stop();
Console.WriteLine("Image sharp resize: " + sw1.ElapsedMilliseconds);
sw1.Restart();
image.Save(output);
sw1.Stop();
Console.WriteLine("Image sharp save: " + sw1.ElapsedMilliseconds);
} |
@nah0y I'm afraid, there is no hardware SIMD acceleration for What is the value of System.Numerics.Vector.IsHardwareAccelerated in release mode? If it's false, the only way to speed up ImageSharp jpeg encoder/decoder is to upgrade to the latest mono framework/runtime. (You probably need to build from sources.) |
Renamed the issue to hold more information about the context. |
Hey guys! Sorry for the wait, I'm back with more info :) I tried on my new Macbook Pro and same result. 9762ms. I don't understand why you wrote this :/
For info, in the output console I have around 12 threads that are started one after the other:
And from what I understand it's because of Vector.IsHardwareAccelerated is false and I need the latest mono runtime (thanks @antonfirsov for clarifying that). If I don't want to build from sources and wait for an update, it's an update of Mono right? Like currently they're at 4.6, so I'll have to wait for 4.7. I'll try to give it a try when it's available if I don't forget 😄 |
And @dlemstra, here's the result: Image sharp read: 5360 |
@nah0y yeah you need a new mono version, 4.8 should be the next one, but I see no info about Thanks for sharing your results. Looking at resize performance is on my list. Strange it's that slow on Mono. |
Yes strange ;) |
@nah0y I don't know if you are still interested, but recently I figured out that SIMD support will be shipped with mono 5.0. We are also working on perf. improvements meanwhile. |
@antonfirsov Hey! Thanks for the news. I finally did it another way. But I'm still interested to see how it evolves! |
Hello, I'm experiencing the same issue on Xamarin Andoid version 7.3 (based on Mono 5). ImageSharp version: 1.0.0-alpha9-00054 |
@clegendre Unfortunately I'm unfamiliar with mobile development and the details of the Xamarin architecture. Also: What is the value of System.Numerics.Vector.IsHardwareAccelerated on your device? Are you sure you tested it in release mode? It seems, that it's not necessary to decode the image pixels in your use case, only the exif data + resave the modified exif with the original pixel data. @JimBobSquarePants shouldn't we add support for this? |
@antonfirsov I believe a standalone metadata editor would be the best tool for that job of which there are several out in the wild. Could we build one? Yeah certainly, Probably pretty easy with the existing tools we have now but trying to configure the existing decoders to only parse metadata while ignoring the pixels seems like it would add a lot of complexity and overhead to our code. @clegendre Could you do me a favor and check the value Anton asked for and also post a code sample + device specifications. 1 min is slow... crazy slow even without SIMD. I don't see how we are doing enough work to even cause that much time to be consumed. |
System.Numerics.Vector.IsHardwareAccelerated is set to true. We've also tested on a new Lenovo smartphone under Android 7: images taken with the camera are slightly bigger, but even with a better proc, loading then saving in memory took approximatively 20-30 seconds. @antonfirsov We managed to do it another way, by setting the Exifs directly on the Camera before the image is taken (this is indeed the right way to do that). Thumbnail is done using the native Android API. @JimBobSquarePants I'll try to post a repro sample this weekend. BTW, I love your library and the API design is fantastic, you're making a great job! |
Description
I'm using Mono and Xamarin Studio for that. I'm simply trying to resize a big picture (5184x3456 - 8.2MB) and it takes 12sc to complete.
Steps to Reproduce
I created a simple console project, added Nuget dependencies to ImageSharp. And I'm using this in the Program.cs:
System Configuration
The text was updated successfully, but these errors were encountered: