Skip to content

[WEBP] SaveImage is taking more than x100 times slower in AWS Instance than my local machine #2125

Closed
@christallire

Description

@christallire

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

2.1.1

Other ImageSharp packages and versions

None

Environment (Operating system, version and so on)

ARM64/Ubuntu/k8s

.NET Framework version

.NET 6

Description

Hi guys,

I've observed increased processing time of Image in arm64 VM environment.
It's similar to this (#2104) issue but slightly different.

Image service is running in k8s with an unlimited CPU budget and is supposed to process a lot of images concurrently.

Pod info

# uname -a
Linux image-service-8566cd55f6-f6hkb 5.4.188-104.359.amzn2.aarch64 #1 SMP Thu Apr 14 20:53:17 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

My local test of an image save takes 16ms, but in VM takes 1,000ms to 10,000ms (depending on size, 10 seconds with ~2MB jpg)

Steps to Reproduce

I've run this code in the thread pool and it ran into thread pool starvation almost immediately, lol.

Code

    private async Task<Stream> ConvertImage(Stream stream)
    {
        using var image = await Image.LoadAsync(stream);
        var imageStream = new MemoryStream();

        await image.SaveAsync(imageStream, new WebpEncoder()
        {
            FileFormat = WebpFileFormatType.Lossy,
        });
        
        return imageStream;
    }

Note that the stream used to call the method is MemoryStream

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions