### ImageMagick version

7.1.1-11

### Operating system

MacOS

### Operating system, version and so on

13.4 (arm64)

### Description

Hi, hope your day is going well!

I have a script that does a batch compare of images in two folders, outputting to a third. This used to be incredibly speedy when used in conjunction with the `multiprocessing` and `subprocess` Python modules using older versions of ImageMagick (even old ImageMagick 6 ones). 

Since a version upgrade to 7.1.1-11 (from which version I don't entirely remember, brew annoyingly doesn't keep a log of this stuff), this has been unusably slow. Due to this issue it is far quicker to simply do the operations in series on one process, which is obviously significantly slower than running them in parallel, as previously.

While the hanging operations are happening, my CPU is (correctly?) pinned at 100%, but producing an output several orders of magnitude slower than with previous versions.

There is never a crash, it just hangs, so there is no crash log.

Any help would be appreciated!

### Steps to Reproduce

The following Python code reveals a major discrepency between ImageMagick 6/7 when called from multiple processes, especially on arm64 macOS.

With 30 dummy images (of size 1024x1024) in dir1, and duplicated to dir2, the speed of the following code is as follows:
ImageMagick 7.1.1-11_1 : 69.6 seconds
ImageMagick 6.9.12-89 : 1.2 seconds

```
import time
import subprocess
import multiprocessing
from pathlib import Path
from functools import partial


MAGICK = Path("/opt/homebrew/Cellar/imagemagick/7.1.1-11_1/bin/magick")
COMPARE = Path("/opt/homebrew/Cellar/imagemagick@6/6.9.12-89/bin/compare")

def compare_func(path_one, im_ver):
    if im_ver >= 7:
        args = [MAGICK, "compare"]
    else:
        args = [COMPARE]
    path_two = Path("dir2", path_one.name)
    out_path = Path("outdir", path_one.name)
    args.extend([path_one, path_two, out_path])
    subprocess.run(args, check=False)
    return f"Done {path_two}"


if __name__ == "__main__":
    images = Path("dir1").glob("*.png")
    start = time.perf_counter()
    with multiprocessing.Pool() as pool:
        for res in pool.imap_unordered(func=partial(compare_func, im_ver=7), iterable=images):
            print(res)

    print(f"Took {time.perf_counter() - start:.1f} seconds.")
```


### Images

_No response_
"magick compare" hangs/unusably slow when called from multiple processes.
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : "magick compare" hangs/unusably slow when called from multiple processes.
Issue date:

--- start body ---
### ImageMagick version

7.1.1-11

### Operating system

MacOS

### Operating system, version and so on

13.4 (arm64)

### Description

Hi, hope your day is going well!

I have a script that does a batch compare of images in two folders, outputting to a third. This used to be incredibly speedy when used in conjunction with the `multiprocessing` and `subprocess` Python modules using older versions of ImageMagick (even old ImageMagick 6 ones). 

Since a version upgrade to 7.1.1-11 (from which version I don't entirely remember, brew annoyingly doesn't keep a log of this stuff), this has been unusably slow. Due to this issue it is far quicker to simply do the operations in series on one process, which is obviously significantly slower than running them in parallel, as previously.

While the hanging operations are happening, my CPU is (correctly?) pinned at 100%, but producing an output several orders of magnitude slower than with previous versions.

There is never a crash, it just hangs, so there is no crash log.

Any help would be appreciated!

### Steps to Reproduce

The following Python code reveals a major discrepency between ImageMagick 6/7 when called from multiple processes, especially on arm64 macOS.

With 30 dummy images (of size 1024x1024) in dir1, and duplicated to dir2, the speed of the following code is as follows:
ImageMagick 7.1.1-11_1 : 69.6 seconds
ImageMagick 6.9.12-89 : 1.2 seconds

```
import time
import subprocess
import multiprocessing
from pathlib import Path
from functools import partial


MAGICK = Path("/opt/homebrew/Cellar/imagemagick/7.1.1-11_1/bin/magick")
COMPARE = Path("/opt/homebrew/Cellar/imagemagick@6/6.9.12-89/bin/compare")

def compare_func(path_one, im_ver):
    if im_ver >= 7:
        args = [MAGICK, "compare"]
    else:
        args = [COMPARE]
    path_two = Path("dir2", path_one.name)
    out_path = Path("outdir", path_one.name)
    args.extend([path_one, path_two, out_path])
    subprocess.run(args, check=False)
    return f"Done {path_two}"


if __name__ == "__main__":
    images = Path("dir1").glob("*.png")
    start = time.perf_counter()
    with multiprocessing.Pool() as pool:
        for res in pool.imap_unordered(func=partial(compare_func, im_ver=7), iterable=images):
            print(res)

    print(f"Took {time.perf_counter() - start:.1f} seconds.")
```


### Images

_No response_
--- end body ---
