Crystal: Implement and use vfork when possible

Created on 6 Oct 2019  路  1Comment  路  Source: crystal-lang/crystal

We use fork/exec for running processes. Although it has some benefits regarding process isolation, it leads to higher memory demand.

For example, some of the crashes when building the compiler in 32 bits are when running the run macro to embed tool init .ecr templates.

In Go, vfork is used when available: https://github.com/golang/go/blob/master/src/syscall/exec_linux.go.

When the API is known for sure that running program needs to wait for the subprocess to finish in order to continue there could be a benefit of using vfork.

feature performance topicsystem

Most helpful comment

Maybe also check posix_spawn as an alternative? It internally uses vfork over fork on linux when possible.

>All comments

Maybe also check posix_spawn as an alternative? It internally uses vfork over fork on linux when possible.

Was this page helpful?
0 / 5 - 0 ratings