How to debug copy-on-write?

We have code that relies on widespread use fork. We started to encounter performance problems, and one of our hypotheses is that we have a lot of losses when copy-by-copy occurs in forked processes.

Is there a way to determine when and how copying and recording occurs in order to get a detailed idea of ​​this process.

My platform is OSX, but more general information is also appreciated.

+4
source share
1 answer

There are several ways to get this information in OS X. If you are satisfied with viewing the copy-write information from the command line, you can use the tool vm_statat intervals. For example, it vm_stat 0.5will print full statistics twice per second. One of the columns is the number of copy-write errors.

, - , "", OS X. , , , VM, . . -, , .

, , ( ) API VM. , ​​ vm_statistics, host_statistics. , :

mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
vm_statistics_data_t vmstats;
kern_return_t host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstats, &count);

vmstats , cow_faults, , copy-on-write. /usr/include/mach/vm_*, .

+2

Source: https://habr.com/ru/post/1668432/


All Articles