Use mmap, not vm_allocate, on Mac

RESOLVED WORKSFORME

Status

()

Core
JavaScript Engine
RESOLVED WORKSFORME
6 years ago
6 years ago

People

(Reporter: Igor Bukanov, Assigned: Igor Bukanov)

Tracking

({perf})

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

6 years ago
Created attachment 564533 [details]
test C program

Currently the GC chunk allocator uses vm_allocate, not mmap, on Mac OS X, to allocate GC chunks. However on OSX 10.7 those functions are significantly slower that mmap. The attached test C program tests that via repeatedly allocating a series of 1MB chunks and then releasing them using either mmap or vm_allocate.

On Mac Mini with OS X 10.7I get for a typical run using vm_allocate:

@users-Mac-mini~/s> time ./a.out vm

real    0m0.045s
user    0m0.004s
sys     0m0.041s

With mmap numbers become:

@users-Mac-mini~/s> time ./a.out mmap

real    0m0.026s
user    0m0.003s
sys     0m0.016s

That is, the program runs 2 times faster.

If I change the chunk size from 1MB to 64K, then the number becomes:

@users-Mac-mini~/s> time ./a.out vm

real    0m3.134s
user    0m0.065s
sys     0m3.069s

@users-Mac-mini~/s> time ./a.out mmap

real    0m2.767s
user    0m0.043s
sys     0m2.717s

Which is still 13% faster.

Given this results I suggest to use mmap for chunk allocation on MAC OSX.
Do you have any indication that the functions are the same speed on 10.{5,6}?
(Assignee)

Comment 2

6 years ago
(In reply to Justin Lebar [:jlebar] from comment #1)
> Do you have any indication that the functions are the same speed on 10.{5,6}?

I do not know about older MACs. I plan to prepare a patch and see how it affects Talos try server runs.
(Assignee)

Comment 3

6 years ago
Created attachment 564667 [details] [diff] [review]
v1

The patch removes Mac-specific code that uses vm-allocate so now Mac uses the chunk allocation based on mmap code. In the same time the patch optimizes that to take advantage of munmap ability to release a part of existing mmap alocation. Also on Windows the code use VirtualAlloc without a commit when searching for unallocated address space where the aligned chunk can be placed.
Assignee: general → igor
(Assignee)

Updated

6 years ago
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.