1*19c3b8c2SApple OSS Distributionsperf_index - This is a tool for gather performance data. perf_index can run in 2*19c3b8c2SApple OSS Distributionstwo modes. In regulular (offline mode) the usage is: 3*19c3b8c2SApple OSS Distributionspref_index type threads size [args] 4*19c3b8c2SApple OSS Distributionswhere type is one of the test types explained below, threads is the number of 5*19c3b8c2SApple OSS Distributionsuserland threads that should preform the task, size is the size of the task and 6*19c3b8c2SApple OSS Distributionsargs are arguments to pass to the test. Currently only the iperf test requires 7*19c3b8c2SApple OSS Distributionsthese arguments. For example if run with the following arguments: 8*19c3b8c2SApple OSS Distributions./perf_index cpu 2 100000000 9*19c3b8c2SApple OSS Distributions 10*19c3b8c2SApple OSS Distributionsiperf will run the cpu workload on two threads with a total work load size of 11*19c3b8c2SApple OSS Distributions100000000. Since the workload is distributed over 2 threads, on a perfectly 12*19c3b8c2SApple OSS Distributionsparallel system, this would take half the time relative to if 1 was specified 13*19c3b8c2SApple OSS Distributionsfor the threads parameter. When finished running perf_index will write the 14*19c3b8c2SApple OSS Distributionsnumber of seconds it took to standard out as a decimal number. Some of the test 15*19c3b8c2SApple OSS Distributionstypes have initialization and teardown steps, and these steps are not counted 16*19c3b8c2SApple OSS Distributionstowards the time. The workload and the time it takes to be performed differs 17*19c3b8c2SApple OSS Distributionsquite drastically between test type, so you may need to play around with the 18*19c3b8c2SApple OSS Distributionssize argument to find a value that will complete in a reasonable amount of time. 19*19c3b8c2SApple OSS Distributions 20*19c3b8c2SApple OSS DistributionsIn online mode, perf_index is invoked like so: 21*19c3b8c2SApple OSS Distributionsperf_index remote server 22*19c3b8c2SApple OSS Distributionswhere remote is exactly the string "remote" and server is the control host to 23*19c3b8c2SApple OSS Distributionsconnect to. This tells the program to connect to the specified server and wait 24*19c3b8c2SApple OSS Distributionsfor instructions. The server is run by running the test_controller.py python 25*19c3b8c2SApple OSS Distributionsscript with the following arguments: 26*19c3b8c2SApple OSS Distributionstest_controller.py num_clients type threads size 27*19c3b8c2SApple OSS DistributionsThe server will wait for num_client to connect. It will then pass type, threads, 28*19c3b8c2SApple OSS Distributionsand size to each of those clients, who will run the initialization code and 29*19c3b8c2SApple OSS Distributionsreport back to the server. Once the initialization is run by every client, the 30*19c3b8c2SApple OSS Distributionsserver will give the OK to every client to run the workload and begin timing. 31*19c3b8c2SApple OSS DistributionsWhen done, each client reports back to the server. Once the server hears back 32*19c3b8c2SApple OSS Distributionsfrom every client, it will stop timing and output the elapsed time. 33*19c3b8c2SApple OSS Distributions 34*19c3b8c2SApple OSS Distributions 35*19c3b8c2SApple OSS DistributionsTest Types: 36*19c3b8c2SApple OSS DistributionsNote this implementations are subject to change, for an authoritative source, 37*19c3b8c2SApple OSS Distributionssee the source code 38*19c3b8c2SApple OSS Distributionscpu - calculates n md5 sums 39*19c3b8c2SApple OSS Distributionsmemory - initializes by allocating memory equal to half the RAM on the machine, 40*19c3b8c2SApple OSS Distributionsthen writes a byte to every page to ensure it is paged in. Then copies n bytes 41*19c3b8c2SApple OSS Distributionsfrom the first half of memory to the second. If the allocated space is less than 42*19c3b8c2SApple OSS Distributionsn/2, it keeps repeating the copies until n bytes are copied. 43*19c3b8c2SApple OSS Distributionssyscall - calls the getppid(2) system call n times 44*19c3b8c2SApple OSS Distributionsfault - performs n page faults by mmaping a large chunk of memory, toggling the 45*19c3b8c2SApple OSS Distributionswrite protection bit, and writing to each page 46*19c3b8c2SApple OSS Distributionszfod - performs n zero fill on demands, by mmaping a large chunk of memory and 47*19c3b8c2SApple OSS Distributionswriting to each page 48*19c3b8c2SApple OSS Distributionsfile_create - creates n files (in the same directory) with the open(2) system 49*19c3b8c2SApple OSS Distributionscall 50*19c3b8c2SApple OSS Distributionsfile_write - writes n bytes to files on disk. There is one file per each thread. 51*19c3b8c2SApple OSS Distributionsfile_read - initializes by creating one large file on disk per each thread. 52*19c3b8c2SApple OSS DistributionsThen reads n bytes total from all the files. If there are less than n bytes in 53*19c3b8c2SApple OSS Distributionsthe files, repeats reading from the beginning. 54*19c3b8c2SApple OSS Distributionsram_file_create - same as file_create but on a ram disk 55*19c3b8c2SApple OSS Distributionsram_file_read - same as file_read but on a ram disk 56*19c3b8c2SApple OSS Distributionsram_file_write - same as file_write but on a ram disk 57*19c3b8c2SApple OSS Distributionsiperf - uses iperf to send n bytes over the network to the designated host 58*19c3b8c2SApple OSS Distributionsspecified as args 59*19c3b8c2SApple OSS Distributionscompile - compiles xnu using make. This currently does a single compile and 60*19c3b8c2SApple OSS Distributionsignores the size argument 61*19c3b8c2SApple OSS Distributions 62*19c3b8c2SApple OSS DistributionsBuilding: 63*19c3b8c2SApple OSS Distributionsperf_index is built automatically by BNI for both Mac (10.9 and later), and iOS 64*19c3b8c2SApple OSS Distributions(7 and later) trains, and is delivered on AppleInternal builds in 65*19c3b8c2SApple OSS Distributions/AppleInternal/CoreOS/perf_index. It is built as part of the xnu_quick_test 66*19c3b8c2SApple OSS Distributionsbuild alias, so you can also find a copy on ~rc at: 67*19c3b8c2SApple OSS Distributions~rc/Software/$RELEASE/Updates/$RELEASEVERSION/Roots/xnu_quick_test/AppleInternal/CoreOS/perf_index. 68*19c3b8c2SApple OSS Distributions 69*19c3b8c2SApple OSS DistributionsAlternatively you can build it yourself using make like so: 70*19c3b8c2SApple OSS DistributionsSDKROOT=/path/to/sdk make 71*19c3b8c2SApple OSS Distributions 72*19c3b8c2SApple OSS DistributionsFor example: 73*19c3b8c2SApple OSS Distributions# build for Mac, current OS 74*19c3b8c2SApple OSS DistributionsSDKROOT=/ make 75*19c3b8c2SApple OSS Distributions# build for iOS 76*19c3b8c2SApple OSS DistributionsSDKROOT=`xcodebuild -sdk iphoneos.internal -version Path` make 77*19c3b8c2SApple OSS Distributions 78*19c3b8c2SApple OSS DistributionsBy default xnu builds all-way fat, but you can restrict this by explicitly 79*19c3b8c2SApple OSS Distributionsspecifying architectures like so: 80*19c3b8c2SApple OSS Distributions# build for only armv7 and armv7s 81*19c3b8c2SApple OSS DistributionsSDKROOT=`xcodebuild -sdk iphoneos.internal -version Path` make ARCH="armv7 armv7s" 82