Skip to content

Slow execution time when running inside Docker container on a M1 CPU (aarch64) #1

@david224-ic

Description

@david224-ic

What happened?

I noticed that after implementing envkey-php in my project page loading got at lot slower only when running inside my Docker container (I'm on and M1 Mac).
I decided to take a look at what was causing the slow down with a profiler and I found out that a shell exec called by envkeys-php's fetch() function was responsible, located at:

$res = rtrim(shell_exec($cmd));
)

The visualization of the profiler's results:
image

My analysis

I decided to try and debug it, and found out that this class ends up matching envkey-source binary for linux/amd64 when used inside the container, which runs a lot slower than the linux/arm64 binary on my machine of course.
I believe the cause of this behavior lies on the code (in the snipped bellow) that calls php_uname('m') to determine the cpu arch, but it can only match 'arm', while running uname -m inside the container yields 'aarch64'.

} elseif (stristr(PHP_OS, 'DARWIN') && stripos(php_uname('m'), 'arm') !== false) {

image

System Information

Hardware: MacBook Air
Chip: Apple M1 (aarch64)
Memory: 8 GB
OS: macOS 14.5 (Sonoma)

envkey-php version

2.4.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions