mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Make fork() go 30% faster
This change makes fork() go nearly as fast as sys_fork() on UNIX. As for Windows this change shaves about 4-5ms off fork() + wait() latency. This is accomplished by using WriteProcessMemory() from the parent process to setup the address space of a suspended process; it is better than a pipe
This commit is contained in:
parent
98c5847727
commit
0b3c81dd4e
44 changed files with 769 additions and 649 deletions
|
@ -16,13 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/intrin/describeflags.h"
|
||||
#include "libc/intrin/strace.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/nt/memory.h"
|
||||
|
||||
__msabi extern typeof(VirtualProtect) *const __imp_VirtualProtect;
|
||||
#include "libc/nt/runtime.h"
|
||||
|
||||
/**
|
||||
* Protects memory on the New Technology.
|
||||
|
@ -31,12 +26,6 @@ __msabi extern typeof(VirtualProtect) *const __imp_VirtualProtect;
|
|||
textwindows bool32 VirtualProtect(void *lpAddress, uint64_t dwSize,
|
||||
uint32_t flNewProtect,
|
||||
uint32_t *lpflOldProtect) {
|
||||
bool32 bOk;
|
||||
bOk = __imp_VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect);
|
||||
if (!bOk)
|
||||
__winerr();
|
||||
NTTRACE("VirtualProtect(%p, %'zu, %s, [%s]) → %hhhd% m", lpAddress, dwSize,
|
||||
DescribeNtPageFlags(flNewProtect),
|
||||
DescribeNtPageFlags(*lpflOldProtect), bOk);
|
||||
return bOk;
|
||||
return VirtualProtectEx(GetCurrentProcess(), lpAddress, dwSize, flNewProtect,
|
||||
lpflOldProtect);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue