Process virtual memory cleanup takes quite a lot of time
Process virtual memory cleanup takes quite a lot of time
- Subject: Process virtual memory cleanup takes quite a lot of time
- From: Alexander Potapenko <email@hidden>
- Date: Tue, 24 Jan 2012 12:53:16 +0400
Hi all,
The following program:
=====================
$ cat p.c
#include <sys/mman.h>
int main() {
void *t = mmap(0, 0x00000fffffffffffUL, PROT_READ| PROT_WRITE,
MAP_ANON | MAP_PRIVATE | MAP_NORESERVE, -1, 0);
}
=====================
runs for half a second on my 64-bit Snow Leopard machine:
=====================
$ time ./p
real 0m0.545s
user 0m0.000s
sys 0m0.544s
=====================
According to Shark, most of the time is spent in pmap_remove at exit time:
=====================
# Report 5 - session_008.mshark - Time Profile of PID #98012
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 59.9%, pmap_remove, mach_kernel
| + 59.9%, vm_map_lookup_locked, mach_kernel
| | + 59.9%, vm_map_remove, mach_kernel
| | | + 59.9%, task_terminate_internal, mach_kernel
| | | | + 59.9%, exit1, mach_kernel
| | | | | + 59.9%, exit, mach_kernel
| | | | | | 59.9%, unix_syscall64, mach_kernel
- 12.0%, pmap64_pde, mach_kernel
- 10.7%, pmap64_pdpt, mach_kernel
- 5.0%, vm_map_lookup_locked, mach_kernel
- 2.7%, zalloc_canblock, mach_kernel
- 2.2%, pmap_pde, mach_kernel
- 1.8%, lck_mtx_lock_spin, mach_kernel
- 1.6%, vm_map_entry_insert, mach_kernel
- 1.0%, lck_mtx_unlock_darwin10, mach_kernel
- 0.5%, hw_lock_to, mach_kernel
=====================
This surprises me, because I thought that a process teardown should be
rather cheap (it actually is on Linux).
Is it possible to somehow help the kernel with that from the userspace?
Rationale: AddressSanitizer
(http://code.google.com/p/address-sanitizer/), an LLVM-based tool for
memory bugs detection,
maps such a huge amount of memory to shadow the address space of the
process being debugged.
For large applications (like Chrome or WebKit) the virtual page table
lookups are not noticeable at all.
But our test suite that runs hundreds of tests each doing a fork+exec
one by one is very slow because of that.
TIA,
Alexander Potapenko
Software Engineer
Google Moscow
--
Alexander Potapenko
Software Engineer
Google Moscow
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden