PERF: Use `-O2` gcc compilation flag for imagemagick (#768)
authorAlan Guo Xiang Tan <gxtan1990@gmail.com>
Mon, 5 Feb 2024 23:43:15 +0000 (07:43 +0800)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2024 23:43:15 +0000 (07:43 +0800)
commita03cdcb2578d79d37440606add42676bd55c3c33
tree5db20e6dda63de0c6d7e414019cbab39a030c3ce
parent1964d1737a36b4f46ed3c0bc8b25db24e1a9a0c2
PERF: Use `-O2` gcc compilation flag for imagemagick (#768)

Why this change?

We have noticed that our compiled imagemagick binary is slower than the
distributed binaries in the same environment and started debugging why.
One thing I noticed is that distributed binaries usually include the
`-O2` gcc compilation flag. When applying it locally, I saw significant
speed up.

Without -O2 flag:

```
root@1d7277f72a4f:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png

real 0m3.376s
user 0m6.355s
sys 0m0.410s
root@1d7277f72a4f:/# time identify -format "%Q" random_image.png
92
real 0m1.018s
user 0m0.883s
sys 0m0.135s
```

With -O2 flag:

```
root@0779afa71102:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png

real 0m1.118s
user 0m1.555s
sys 0m1.680s
root@0779afa71102:/# time identify -format "%Q" random_image.png
92
real 0m0.330s
user 0m0.197s
sys 0m0.133s
```
image/base/install-imagemagick