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

M1 macbook air vs windows speed discrepancy #3091

Closed
jahbolero opened this issue Feb 14, 2022 · 4 comments
Closed

M1 macbook air vs windows speed discrepancy #3091

jahbolero opened this issue Feb 14, 2022 · 4 comments
Labels

Comments

@jahbolero
Copy link

What are you trying to achieve?
Merge multiple photos(Hundreds)

Have you searched for similar questions?
Yes
Are you able to provide a minimal, standalone code sample that demonstrates this question?
No
Are you able to provide a sample image that helps explain the question?
No

I've been trying to run the sharp composite command to generate a large image set(1k).
Running on my windows machine, it takes roughly 15 minutes to generate a thousand, while on a MacBook m1 air it takes 100 minutes to do the same number.

Is there any incompatibility issue with the recent m1 chips? Or perhaps config that needs to be done for it to perform optimally?

@lovell
Copy link
Owner

lovell commented Feb 14, 2022

There's not a lot of information to go on, but my best guess with the very limited detail provided here would be that if the task is CPU bound then you might be using Rosetta x64 emulation on the M1 (e.g. via Node.js 14).

For more help please provide complete, minimal, standalone code and image(s) that allows someone else to reproduce this.

@jahbolero
Copy link
Author

My apologies for the delay.
The same has been tested using the latest node version on a MacBook m1 and was only 20% faster than with the older node version.

Just additional details for comparison:
Windows:Ryzen 7 4000
Macbook:M1 MacBook Air

Below is a sample snippet of generating multiple images.

const compositeImage = async (images) => {
  let inputArray = [];
  for (var i = 1; i < images.length; i++) {
    inputArray.push({ input: `${images[i]}` });
  }
  sharp(`${images[0]}`).composite(inputArray).toFile(`${1}.png`);
};

@lovell
Copy link
Owner

lovell commented Feb 19, 2022

Please see #2286

@lovell lovell closed this as completed Feb 19, 2022
@jahbolero
Copy link
Author

jahbolero commented Feb 19, 2022

I will try replicating the case again with the newest commit. However, there's something that I failed to add, which separates this issue with #2286. The complete code to replicate what was done in both machines for the case is below.

Given the difference in processing power, expectedly the MacBook m1 should be significantly faster than the windows ryzen 7 4000.

const sharp = require('sharp');

const compositeImage = async (images, id) => {
  let inputArray = [];
  for (let i = 1; i < images.length; i++) {
    inputArray.push({ input: `${images[i]}` });
  }
  await sharp(`${images[0]}`).composite(inputArray).toFile(`output/${id}.png`);
};

(async () => {
  let imageArray = ['1.png', '2.png', '3.png', '4.png'];
  console.log('start:' + new Date().toLocaleTimeString());
  var i = 0;
  while (i < 1000) {
    await compositeImage(imageArray, i);
    i++;
  }
  console.log('end:' + new Date().toLocaleTimeString());
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants