photostructure / batch-cluster.js

Parallelized and efficient Node.js support for batch-mode child processes
https://photostructure.github.io/batch-cluster.js/
MIT License
14 stars 3 forks source link

exiftool-vendored v15.11.0 seems to be reading tags from ICC profile files much slower #15

Closed rubiesonthesky closed 2 years ago

rubiesonthesky commented 2 years ago

Describe the bug

I have test setup for reading 13 icc profile files from disk and using exiftool-vendored to read their tags and return metadata.ICC_Profile.ProfileDescription. After updating to 15.11.0, my test setup fails because it goes over default mocha time limit (2000ms). When setting really big timeout, this test takes to complete 7783ms. While I think there are a lot thinks to optimize in the actual code, it was finishing close to 2000 ms (eg. 1895ms) with version 15.10.1, this newer version takes a lot more time to do it.

I timed the function in the real app (running under ts-node) and the result is same.

I suspect something in the batch-cluster library changed and could be the problem? I did not see anything else really changing between these too versions.

Actually, I did not some testing and overriding batch-cluster to be version 8 produces same result with 15.11.0 than with 15.10.1. -> test does not fail.

To Reproduce

So I have some code like this

  export async function getProfilesFromFolder(dir: string) {
    const files = await promises.readdir(dir);
    const profileFiles = files.map(async file => await exifToolEngine.getProfileNameFromFile(path.resolve(dir, file)));
    return Promise.all(profileFiles);
  }

  async getProfileNameFromFile(filePath: string) {
    const metadata = await this.exifTool.read(filePath, ["-j", "-g"]);
    return Promise.resolve({file: filePath, name: metadata?.ICC_Profile?.ProfileDescription});
  }

And them my mocha test is something like this

    it('get default profiles', async function () {
      const profiles = await getProfilesFromFolder(profileDir());
      assert.equal(profiles?.length, 13);
    });

Expected behavior

I did not expect the function to be this much slower.

Environment (please complete the following information):

mceachen commented 2 years ago

Thanks for reporting. I'll try to reproduce this on my mac today.

mceachen commented 2 years ago

I just released batch-cluster v10.1.1 which should resolve this issue.

rubiesonthesky commented 2 years ago

Thank you for very quick fix! Can confirm that this fixed the issue :)