-
Notifications
You must be signed in to change notification settings - Fork 705
/
perfcollect
executable file
·2186 lines (1929 loc) · 63.3 KB
/
perfcollect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#############################################################################################################
# .NET Performance Data Collection Script
#############################################################################################################
#############################################################################################################
#
# ***** HOW TO USE THIS SCRIPT *****
#
# This script can be used to collect and view performance data collected with perf_event on Linux.
# It's job is to make it simple to collect performance traces.
#
# How to collect a performance trace:
# 1. Prior to starting the .NET process, set the environment variable COMPlus_PerfMapEnabled=1.
# This tells the runtime to emit information that enables perf_event to resolve JIT-compiled code symbols.
#
# 2. Setup your system to reproduce the performance issue you'd like to capture. Data collection can be
# started on already running processes.
#
# 3. [Usage #1] use "collect" command
# - Run this script: sudo ./perfcollect collect samplePerfTrace. This will start data collection.
# - Let the repro run as long as you need to capture the performance problem.
# - Hit CTRL+C to stop collection.
#
# [Usage #2] use "start" and "stop" command
# - Run this script: sudo ./perfcollect start samplePerfTrace. This will start data colletion.
# - Let the repro run as long as you need to capture the performance problem.
# - Run: sudo ./perfcollect stop samplePerfTrace. This will stop collection.
#
# 4. When collection is stopped, the script will create a trace.zip file matching the name specified on the
# command line. This file will contain the trace, JIT-compiled symbol information, and all debugging
# symbols for binaries referenced by this trace that were available on the machine at collection time.
#
# How to view a performance trace:
# 1. Run this script: ./perfcollect view samplePerfTrace.trace.zip
# This will extract the trace, place and register all symbol files and JIT-compiled symbol information
# and start the perf_event viewer. By default, you will be looking at a callee view - stacks are ordered
# top down. For a caller or bottom up view, specify '-graphtype caller'.
#############################################################################################################
######################################
## FOR DEBUGGING ONLY
######################################
# set -x
######################################
## Collection Options
## NOTE: These values represent the collection defaults.
######################################
# Set when we parse command line arguments to determine if we should enable specific collection options.
collect_cpu=1
collect_threadTime=0
collect_offcpu=0
collect_system=0
######################################
## .NET Event Categories
######################################
# Separate GCCollectOnly list because our LTTng implementation doesn't set tracepoint verbosity.
# Once tracepoint verbosity is set, we can set verbosity and collapse this with DotNETRuntime_GCKeyword.
declare -a DotNETRuntime_GCKeyword_GCCollectOnly=(
DotNETRuntime:GCStart
DotNETRuntime:GCStart_V1
DotNETRuntime:GCStart_V2
DotNETRuntime:GCEnd
DotNETRuntime:GCEnd_V1
DotNETRuntime:GCRestartEEEnd
DotNETRuntime:GCRestartEEEnd_V1
DotNETRuntime:GCHeapStats
DotNETRuntime:GCHeapStats_V1
DotNETRuntime:GCCreateSegment
DotNETRuntime:GCCreateSegment_V1
DotNETRuntime:GCFreeSegment
DotNETRuntime:GCFreeSegment_V1
DotNETRuntime:GCRestartEEBegin
DotNETRuntime:GCRestartEEBegin_V1
DotNETRuntime:GCSuspendEEEnd
DotNETRuntime:GCSuspendEEEnd_V1
DotNETRuntime:GCSuspendEEBegin
DotNETRuntime:GCSuspendEEBegin_V1
DotNETRuntime:GCCreateConcurrentThread
DotNETRuntime:GCTerminateConcurrentThread
DotNETRuntime:GCFinalizersEnd
DotNETRuntime:GCFinalizersEnd_V1
DotNETRuntime:GCFinalizersBegin
DotNETRuntime:GCFinalizersBegin_V1
DotNETRuntime:GCMarkStackRoots
DotNETRuntime:GCMarkFinalizeQueueRoots
DotNETRuntime:GCMarkHandles
DotNETRuntime:GCMarkOlderGenerationRoots
DotNETRuntime:FinalizeObject
DotNETRuntime:GCTriggered
DotNETRuntime:IncreaseMemoryPressure
DotNETRuntime:DecreaseMemoryPressure
DotNETRuntime:GCMarkWithType
DotNETRuntime:GCPerHeapHistory_V3
DotNETRuntime:GCGlobalHeapHistory_V2
DotNETRuntime:GCCreateConcurrentThread_V1
DotNETRuntime:GCTerminateConcurrentThread_V1
)
declare -a DotNETRuntime_GCKeyword=(
DotNETRuntime:GCStart
DotNETRuntime:GCStart_V1
DotNETRuntime:GCStart_V2
DotNETRuntime:GCEnd
DotNETRuntime:GCEnd_V1
DotNETRuntime:GCRestartEEEnd
DotNETRuntime:GCRestartEEEnd_V1
DotNETRuntime:GCHeapStats
DotNETRuntime:GCHeapStats_V1
DotNETRuntime:GCCreateSegment
DotNETRuntime:GCCreateSegment_V1
DotNETRuntime:GCFreeSegment
DotNETRuntime:GCFreeSegment_V1
DotNETRuntime:GCRestartEEBegin
DotNETRuntime:GCRestartEEBegin_V1
DotNETRuntime:GCSuspendEEEnd
DotNETRuntime:GCSuspendEEEnd_V1
DotNETRuntime:GCSuspendEEBegin
DotNETRuntime:GCSuspendEEBegin_V1
DotNETRuntime:GCAllocationTick
DotNETRuntime:GCAllocationTick_V1
DotNETRuntime:GCAllocationTick_V2
DotNETRuntime:GCAllocationTick_V3
DotNETRuntime:GCCreateConcurrentThread
DotNETRuntime:GCTerminateConcurrentThread
DotNETRuntime:GCFinalizersEnd
DotNETRuntime:GCFinalizersEnd_V1
DotNETRuntime:GCFinalizersBegin
DotNETRuntime:GCFinalizersBegin_V1
DotNETRuntime:GCMarkStackRoots
DotNETRuntime:GCMarkFinalizeQueueRoots
DotNETRuntime:GCMarkHandles
DotNETRuntime:GCMarkOlderGenerationRoots
DotNETRuntime:FinalizeObject
DotNETRuntime:PinObjectAtGCTime
DotNETRuntime:GCTriggered
DotNETRuntime:IncreaseMemoryPressure
DotNETRuntime:DecreaseMemoryPressure
DotNETRuntime:GCMarkWithType
DotNETRuntime:GCJoin_V2
DotNETRuntime:GCPerHeapHistory_V3
DotNETRuntime:GCGlobalHeapHistory_V2
DotNETRuntime:GCCreateConcurrentThread_V1
DotNETRuntime:GCTerminateConcurrentThread_V1
)
declare -a DotNETRuntime_TypeKeyword=(
DotNETRuntime:BulkType
)
declare -a DotNETRuntime_GCHeapDumpKeyword=(
DotNETRuntime:GCBulkRootEdge
DotNETRuntime:GCBulkRootConditionalWeakTableElementEdge
DotNETRuntime:GCBulkNode
DotNETRuntime:GCBulkEdge
DotNETRuntime:GCBulkRootCCW
DotNETRuntime:GCBulkRCW
DotNETRuntime:GCBulkRootStaticVar
)
declare -a DotNETRuntime_GCSampledObjectAllocationHighKeyword=(
DotNETRuntime:GCSampledObjectAllocationHigh
)
declare -a DotNETRuntime_GCHeapSurvivalAndMovementKeyword=(
DotNETRuntime:GCBulkSurvivingObjectRanges
DotNETRuntime:GCBulkMovedObjectRanges
DotNETRuntime:GCGenerationRange
)
declare -a DotNETRuntime_GCHandleKeyword=(
DotNETRuntime:SetGCHandle
DotNETRuntime:DestroyGCHandle
)
declare -a DotNETRuntime_GCSampledObjectAllocationLowKeyword=(
DotNETRuntime:GCSampledObjectAllocationLow
)
declare -a DotNETRuntime_ThreadingKeyword=(
DotNETRuntime:WorkerThreadCreate
DotNETRuntime:WorkerThreadTerminate
DotNETRuntime:WorkerThreadRetire
DotNETRuntime:WorkerThreadUnretire
DotNETRuntime:IOThreadCreate
DotNETRuntime:IOThreadCreate_V1
DotNETRuntime:IOThreadTerminate
DotNETRuntime:IOThreadTerminate_V1
DotNETRuntime:IOThreadRetire
DotNETRuntime:IOThreadRetire_V1
DotNETRuntime:IOThreadUnretire
DotNETRuntime:IOThreadUnretire_V1
DotNETRuntime:ThreadpoolSuspensionSuspendThread
DotNETRuntime:ThreadpoolSuspensionResumeThread
DotNETRuntime:ThreadPoolWorkerThreadStart
DotNETRuntime:ThreadPoolWorkerThreadStop
DotNETRuntime:ThreadPoolWorkerThreadRetirementStart
DotNETRuntime:ThreadPoolWorkerThreadRetirementStop
DotNETRuntime:ThreadPoolWorkerThreadAdjustmentSample
DotNETRuntime:ThreadPoolWorkerThreadAdjustmentAdjustment
DotNETRuntime:ThreadPoolWorkerThreadAdjustmentStats
DotNETRuntime:ThreadPoolWorkerThreadWait
DotNETRuntime:ThreadPoolWorkingThreadCount
DotNETRuntime:ThreadPoolIOPack
DotNETRuntime:GCCreateConcurrentThread_V1
DotNETRuntime:GCTerminateConcurrentThread_V1
)
declare -a DotNETRuntime_ThreadingKeyword_ThreadTransferKeyword=(
DotNETRuntime:ThreadPoolEnqueue
DotNETRuntime:ThreadPoolDequeue
DotNETRuntime:ThreadPoolIOEnqueue
DotNETRuntime:ThreadPoolIODequeue
DotNETRuntime:ThreadCreating
DotNETRuntime:ThreadRunning
)
declare -a DotNETRuntime_NoKeyword=(
DotNETRuntime:ExceptionThrown
DotNETRuntime:Contention
DotNETRuntime:RuntimeInformationStart
DotNETRuntime:EventSource
)
declare -a DotNETRuntime_ExceptionKeyword=(
DotNETRuntime:ExceptionThrown_V1
DotNETRuntime:ExceptionCatchStart
DotNETRuntime:ExceptionCatchStop
DotNETRuntime:ExceptionFinallyStart
DotNETRuntime:ExceptionFinallyStop
DotNETRuntime:ExceptionFilterStart
DotNETRuntime:ExceptionFilterStop
DotNETRuntime:ExceptionThrownStop
)
declare -a DotNETRuntime_ContentionKeyword=(
DotNETRuntime:ContentionStart_V1
DotNETRuntime:ContentionStop
DotNETRuntime:ContentionStop_V1
)
declare -a DotNETRuntime_StackKeyword=(
DotNETRuntime:CLRStackWalk
)
declare -a DotNETRuntime_AppDomainResourceManagementKeyword=(
DotNETRuntime:AppDomainMemAllocated
DotNETRuntime:AppDomainMemSurvived
)
declare -a DotNETRuntime_AppDomainResourceManagementKeyword_ThreadingKeyword=(
DotNETRuntime:ThreadCreated
DotNETRuntime:ThreadTerminated
DotNETRuntime:ThreadDomainEnter
)
declare -a DotNETRuntime_InteropKeyword=(
DotNETRuntime:ILStubGenerated
DotNETRuntime:ILStubCacheHit
)
declare -a DotNETRuntime_JitKeyword_NGenKeyword=(
DotNETRuntime:DCStartCompleteV2
DotNETRuntime:DCEndCompleteV2
DotNETRuntime:MethodDCStartV2
DotNETRuntime:MethodDCEndV2
DotNETRuntime:MethodDCStartVerboseV2
DotNETRuntime:MethodDCEndVerboseV2
DotNETRuntime:MethodLoad
DotNETRuntime:MethodLoad_V1
DotNETRuntime:MethodLoad_V2
DotNETRuntime:MethodUnload
DotNETRuntime:MethodUnload_V1
DotNETRuntime:MethodUnload_V2
DotNETRuntime:MethodLoadVerbose
DotNETRuntime:MethodLoadVerbose_V1
DotNETRuntime:MethodLoadVerbose_V2
DotNETRuntime:MethodUnloadVerbose
DotNETRuntime:MethodUnloadVerbose_V1
DotNETRuntime:MethodUnloadVerbose_V2
)
declare -a DotNETRuntime_JitKeyword=(
DotNETRuntime:MethodJittingStarted
DotNETRuntime:MethodJittingStarted_V1
)
declare -a DotNETRuntime_JitTracingKeyword=(
DotNETRuntime:MethodJitInliningSucceeded
DotNETRuntime:MethodJitInliningFailed
DotNETRuntime:MethodJitTailCallSucceeded
DotNETRuntime:MethodJitTailCallFailed
)
declare -a DotNETRuntime_JittedMethodILToNativeMapKeyword=(
DotNETRuntime:MethodILToNativeMap
)
declare -a DotNETRuntime_LoaderKeyword=(
DotNETRuntime:ModuleDCStartV2
DotNETRuntime:ModuleDCEndV2
DotNETRuntime:DomainModuleLoad
DotNETRuntime:DomainModuleLoad_V1
DotNETRuntime:ModuleLoad
DotNETRuntime:ModuleUnload
DotNETRuntime:AssemblyLoad
DotNETRuntime:AssemblyLoad_V1
DotNETRuntime:AssemblyUnload
DotNETRuntime:AssemblyUnload_V1
DotNETRuntime:AppDomainLoad
DotNETRuntime:AppDomainLoad_V1
DotNETRuntime:AppDomainUnload
DotNETRuntime:AppDomainUnload_V1
)
declare -a DotNETRuntime_LoaderKeyword=(
DotNETRuntime:ModuleLoad_V1
DotNETRuntime:ModuleLoad_V2
DotNETRuntime:ModuleUnload_V1
DotNETRuntime:ModuleUnload_V2
)
declare -a DotNETRuntime_SecurityKeyword=(
DotNETRuntime:StrongNameVerificationStart
DotNETRuntime:StrongNameVerificationStart_V1
DotNETRuntime:StrongNameVerificationStop
DotNETRuntime:StrongNameVerificationStop_V1
DotNETRuntime:AuthenticodeVerificationStart
DotNETRuntime:AuthenticodeVerificationStart_V1
DotNETRuntime:AuthenticodeVerificationStop
DotNETRuntime:AuthenticodeVerificationStop_V1
)
declare -a DotNETRuntime_DebuggerKeyword=(
DotNETRuntime:DebugIPCEventStart
DotNETRuntime:DebugIPCEventEnd
DotNETRuntime:DebugExceptionProcessingStart
DotNETRuntime:DebugExceptionProcessingEnd
)
declare -a DotNETRuntime_CodeSymbolsKeyword=(
DotNETRuntime:CodeSymbols
)
declare -a DotNETRuntime_CompilationKeyword=(
DotNETRuntime:TieredCompilationSettings
DotNETRuntime:TieredCompilationPause
DotNETRuntime:TieredCompilationResume
DotNETRuntime:TieredCompilationBackgroundJitStart
DotNETRuntime:TieredCompilationBackgroundJitStop
DotNETRuntimeRundown:TieredCompilationSettingsDCStart
)
# Separate GCCollectOnly list because our LTTng implementation doesn't set tracepoint verbosity.
# Once tracepoint verbosity is set, we can set verbosity and collapse this with DotNETRuntimePrivate_GCPrivateKeyword.
declare -a DotNETRuntimePrivate_GCPrivateKeyword_GCCollectOnly=(
DotNETRuntimePrivate:GCDecision
DotNETRuntimePrivate:GCDecision_V1
DotNETRuntimePrivate:GCSettings
DotNETRuntimePrivate:GCSettings_V1
DotNETRuntimePrivate:GCPerHeapHistory
DotNETRuntimePrivate:GCPerHeapHistory_V1
DotNETRuntimePrivate:GCGlobalHeapHistory
DotNETRuntimePrivate:GCGlobalHeapHistory_V1
DotNETRuntimePrivate:PrvGCMarkStackRoots
DotNETRuntimePrivate:PrvGCMarkStackRoots_V1
DotNETRuntimePrivate:PrvGCMarkFinalizeQueueRoots
DotNETRuntimePrivate:PrvGCMarkFinalizeQueueRoots_V1
DotNETRuntimePrivate:PrvGCMarkHandles
DotNETRuntimePrivate:PrvGCMarkHandles_V1
DotNETRuntimePrivate:PrvGCMarkCards
DotNETRuntimePrivate:PrvGCMarkCards_V1
DotNETRuntimePrivate:BGCBegin
DotNETRuntimePrivate:BGC1stNonConEnd
DotNETRuntimePrivate:BGC1stConEnd
DotNETRuntimePrivate:BGC2ndNonConBegin
DotNETRuntimePrivate:BGC2ndNonConEnd
DotNETRuntimePrivate:BGC2ndConBegin
DotNETRuntimePrivate:BGC2ndConEnd
DotNETRuntimePrivate:BGCPlanEnd
DotNETRuntimePrivate:BGCSweepEnd
DotNETRuntimePrivate:BGCDrainMark
DotNETRuntimePrivate:BGCRevisit
DotNETRuntimePrivate:BGCOverflow
DotNETRuntimePrivate:BGCAllocWaitBegin
DotNETRuntimePrivate:BGCAllocWaitEnd
DotNETRuntimePrivate:GCFullNotify
DotNETRuntimePrivate:GCFullNotify_V1
DotNETRuntimePrivate:PrvFinalizeObject
DotNETRuntimePrivate:PinPlugAtGCTime
)
declare -a DotNETRuntimePrivate_GCPrivateKeyword=(
DotNETRuntimePrivate:GCDecision
DotNETRuntimePrivate:GCDecision_V1
DotNETRuntimePrivate:GCSettings
DotNETRuntimePrivate:GCSettings_V1
DotNETRuntimePrivate:GCOptimized
DotNETRuntimePrivate:GCOptimized_V1
DotNETRuntimePrivate:GCPerHeapHistory
DotNETRuntimePrivate:GCPerHeapHistory_V1
DotNETRuntimePrivate:GCGlobalHeapHistory
DotNETRuntimePrivate:GCGlobalHeapHistory_V1
DotNETRuntimePrivate:GCJoin
DotNETRuntimePrivate:GCJoin_V1
DotNETRuntimePrivate:PrvGCMarkStackRoots
DotNETRuntimePrivate:PrvGCMarkStackRoots_V1
DotNETRuntimePrivate:PrvGCMarkFinalizeQueueRoots
DotNETRuntimePrivate:PrvGCMarkFinalizeQueueRoots_V1
DotNETRuntimePrivate:PrvGCMarkHandles
DotNETRuntimePrivate:PrvGCMarkHandles_V1
DotNETRuntimePrivate:PrvGCMarkCards
DotNETRuntimePrivate:PrvGCMarkCards_V1
DotNETRuntimePrivate:BGCBegin
DotNETRuntimePrivate:BGC1stNonConEnd
DotNETRuntimePrivate:BGC1stConEnd
DotNETRuntimePrivate:BGC2ndNonConBegin
DotNETRuntimePrivate:BGC2ndNonConEnd
DotNETRuntimePrivate:BGC2ndConBegin
DotNETRuntimePrivate:BGC2ndConEnd
DotNETRuntimePrivate:BGCPlanEnd
DotNETRuntimePrivate:BGCSweepEnd
DotNETRuntimePrivate:BGCDrainMark
DotNETRuntimePrivate:BGCRevisit
DotNETRuntimePrivate:BGCOverflow
DotNETRuntimePrivate:BGCAllocWaitBegin
DotNETRuntimePrivate:BGCAllocWaitEnd
DotNETRuntimePrivate:GCFullNotify
DotNETRuntimePrivate:GCFullNotify_V1
DotNETRuntimePrivate:PrvFinalizeObject
DotNETRuntimePrivate:PinPlugAtGCTime
)
declare -a DotNETRuntimePrivate_StartupKeyword=(
DotNETRuntimePrivate:EEStartupStart
DotNETRuntimePrivate:EEStartupStart_V1
DotNETRuntimePrivate:EEStartupEnd
DotNETRuntimePrivate:EEStartupEnd_V1
DotNETRuntimePrivate:EEConfigSetup
DotNETRuntimePrivate:EEConfigSetup_V1
DotNETRuntimePrivate:EEConfigSetupEnd
DotNETRuntimePrivate:EEConfigSetupEnd_V1
DotNETRuntimePrivate:LdSysBases
DotNETRuntimePrivate:LdSysBases_V1
DotNETRuntimePrivate:LdSysBasesEnd
DotNETRuntimePrivate:LdSysBasesEnd_V1
DotNETRuntimePrivate:ExecExe
DotNETRuntimePrivate:ExecExe_V1
DotNETRuntimePrivate:ExecExeEnd
DotNETRuntimePrivate:ExecExeEnd_V1
DotNETRuntimePrivate:Main
DotNETRuntimePrivate:Main_V1
DotNETRuntimePrivate:MainEnd
DotNETRuntimePrivate:MainEnd_V1
DotNETRuntimePrivate:ApplyPolicyStart
DotNETRuntimePrivate:ApplyPolicyStart_V1
DotNETRuntimePrivate:ApplyPolicyEnd
DotNETRuntimePrivate:ApplyPolicyEnd_V1
DotNETRuntimePrivate:LdLibShFolder
DotNETRuntimePrivate:LdLibShFolder_V1
DotNETRuntimePrivate:LdLibShFolderEnd
DotNETRuntimePrivate:LdLibShFolderEnd_V1
DotNETRuntimePrivate:PrestubWorker
DotNETRuntimePrivate:PrestubWorker_V1
DotNETRuntimePrivate:PrestubWorkerEnd
DotNETRuntimePrivate:PrestubWorkerEnd_V1
DotNETRuntimePrivate:GetInstallationStart
DotNETRuntimePrivate:GetInstallationStart_V1
DotNETRuntimePrivate:GetInstallationEnd
DotNETRuntimePrivate:GetInstallationEnd_V1
DotNETRuntimePrivate:OpenHModule
DotNETRuntimePrivate:OpenHModule_V1
DotNETRuntimePrivate:OpenHModuleEnd
DotNETRuntimePrivate:OpenHModuleEnd_V1
DotNETRuntimePrivate:ExplicitBindStart
DotNETRuntimePrivate:ExplicitBindStart_V1
DotNETRuntimePrivate:ExplicitBindEnd
DotNETRuntimePrivate:ExplicitBindEnd_V1
DotNETRuntimePrivate:ParseXml
DotNETRuntimePrivate:ParseXml_V1
DotNETRuntimePrivate:ParseXmlEnd
DotNETRuntimePrivate:ParseXmlEnd_V1
DotNETRuntimePrivate:InitDefaultDomain
DotNETRuntimePrivate:InitDefaultDomain_V1
DotNETRuntimePrivate:InitDefaultDomainEnd
DotNETRuntimePrivate:InitDefaultDomainEnd_V1
DotNETRuntimePrivate:InitSecurity
DotNETRuntimePrivate:InitSecurity_V1
DotNETRuntimePrivate:InitSecurityEnd
DotNETRuntimePrivate:InitSecurityEnd_V1
DotNETRuntimePrivate:AllowBindingRedirs
DotNETRuntimePrivate:AllowBindingRedirs_V1
DotNETRuntimePrivate:AllowBindingRedirsEnd
DotNETRuntimePrivate:AllowBindingRedirsEnd_V1
DotNETRuntimePrivate:EEConfigSync
DotNETRuntimePrivate:EEConfigSync_V1
DotNETRuntimePrivate:EEConfigSyncEnd
DotNETRuntimePrivate:EEConfigSyncEnd_V1
DotNETRuntimePrivate:FusionBinding
DotNETRuntimePrivate:FusionBinding_V1
DotNETRuntimePrivate:FusionBindingEnd
DotNETRuntimePrivate:FusionBindingEnd_V1
DotNETRuntimePrivate:LoaderCatchCall
DotNETRuntimePrivate:LoaderCatchCall_V1
DotNETRuntimePrivate:LoaderCatchCallEnd
DotNETRuntimePrivate:LoaderCatchCallEnd_V1
DotNETRuntimePrivate:FusionInit
DotNETRuntimePrivate:FusionInit_V1
DotNETRuntimePrivate:FusionInitEnd
DotNETRuntimePrivate:FusionInitEnd_V1
DotNETRuntimePrivate:FusionAppCtx
DotNETRuntimePrivate:FusionAppCtx_V1
DotNETRuntimePrivate:FusionAppCtxEnd
DotNETRuntimePrivate:FusionAppCtxEnd_V1
DotNETRuntimePrivate:Fusion2EE
DotNETRuntimePrivate:Fusion2EE_V1
DotNETRuntimePrivate:Fusion2EEEnd
DotNETRuntimePrivate:Fusion2EEEnd_V1
DotNETRuntimePrivate:SecurityCatchCall
DotNETRuntimePrivate:SecurityCatchCall_V1
DotNETRuntimePrivate:SecurityCatchCallEnd
DotNETRuntimePrivate:SecurityCatchCallEnd_V1
)
declare -a DotNETRuntimePrivate_StackKeyword=(
DotNETRuntimePrivate:CLRStackWalkPrivate
)
declare -a DotNETRuntimePrivate_PerfTrackPrivateKeyword=(
DotNETRuntimePrivate:ModuleRangeLoadPrivate
)
declare -a DotNETRuntimePrivate_BindingKeyword=(
DotNETRuntimePrivate:BindingPolicyPhaseStart
DotNETRuntimePrivate:BindingPolicyPhaseEnd
DotNETRuntimePrivate:BindingNgenPhaseStart
DotNETRuntimePrivate:BindingNgenPhaseEnd
DotNETRuntimePrivate:BindingLookupAndProbingPhaseStart
DotNETRuntimePrivate:BindingLookupAndProbingPhaseEnd
DotNETRuntimePrivate:LoaderPhaseStart
DotNETRuntimePrivate:LoaderPhaseEnd
DotNETRuntimePrivate:BindingPhaseStart
DotNETRuntimePrivate:BindingPhaseEnd
DotNETRuntimePrivate:BindingDownloadPhaseStart
DotNETRuntimePrivate:BindingDownloadPhaseEnd
DotNETRuntimePrivate:LoaderAssemblyInitPhaseStart
DotNETRuntimePrivate:LoaderAssemblyInitPhaseEnd
DotNETRuntimePrivate:LoaderMappingPhaseStart
DotNETRuntimePrivate:LoaderMappingPhaseEnd
DotNETRuntimePrivate:LoaderDeliverEventsPhaseStart
DotNETRuntimePrivate:LoaderDeliverEventsPhaseEnd
DotNETRuntimePrivate:FusionMessageEvent
DotNETRuntimePrivate:FusionErrorCodeEvent
)
declare -a DotNETRuntimePrivate_SecurityPrivateKeyword=(
DotNETRuntimePrivate:EvidenceGenerated
DotNETRuntimePrivate:ModuleTransparencyComputationStart
DotNETRuntimePrivate:ModuleTransparencyComputationEnd
DotNETRuntimePrivate:TypeTransparencyComputationStart
DotNETRuntimePrivate:TypeTransparencyComputationEnd
DotNETRuntimePrivate:MethodTransparencyComputationStart
DotNETRuntimePrivate:MethodTransparencyComputationEnd
DotNETRuntimePrivate:FieldTransparencyComputationStart
DotNETRuntimePrivate:FieldTransparencyComputationEnd
DotNETRuntimePrivate:TokenTransparencyComputationStart
DotNETRuntimePrivate:TokenTransparencyComputationEnd
)
declare -a DotNETRuntimePrivate_PrivateFusionKeyword=(
DotNETRuntimePrivate:NgenBindEvent
)
declare -a DotNETRuntimePrivate_NoKeyword=(
DotNETRuntimePrivate:FailFast
)
declare -a DotNETRuntimePrivate_InteropPrivateKeyword=(
DotNETRuntimePrivate:CCWRefCountChange
)
declare -a DotNETRuntimePrivate_GCHandlePrivateKeyword=(
DotNETRuntimePrivate:PrvSetGCHandle
DotNETRuntimePrivate:PrvDestroyGCHandle
)
declare -a DotNETRuntimePrivate_LoaderHeapPrivateKeyword=(
DotNETRuntimePrivate:AllocRequest
)
declare -a DotNETRuntimePrivate_MulticoreJitPrivateKeyword=(
DotNETRuntimePrivate:MulticoreJit
DotNETRuntimePrivate:MulticoreJitMethodCodeReturned
)
declare -a DotNETRuntimePrivate_DynamicTypeUsageKeyword=(
DotNETRuntimePrivate:IInspectableRuntimeClassName
DotNETRuntimePrivate:WinRTUnbox
DotNETRuntimePrivate:CreateRCW
DotNETRuntimePrivate:RCWVariance
DotNETRuntimePrivate:RCWIEnumerableCasting
DotNETRuntimePrivate:CreateCCW
DotNETRuntimePrivate:CCWVariance
DotNETRuntimePrivate:ObjectVariantMarshallingToNative
DotNETRuntimePrivate:GetTypeFromGUID
DotNETRuntimePrivate:GetTypeFromProgID
DotNETRuntimePrivate:ConvertToCallbackEtw
DotNETRuntimePrivate:BeginCreateManagedReference
DotNETRuntimePrivate:EndCreateManagedReference
DotNETRuntimePrivate:ObjectVariantMarshallingToManaged
)
declare -a EventSource=(
DotNETRuntime:EventSource
)
declare -a LTTng_Kernel_ProcessLifetimeKeyword=(
sched_process_exec
sched_process_exit
)
######################################
## Global Variables
######################################
# Install without waiting for standard input
forceInstall=0
# Declare an array of events to collect.
declare -a eventsToCollect
# Use Perf_Event
usePerf=1
# Use LTTng
useLTTng=1
# LTTng Installed
lttngInstalled=0
# Collect hardware events
collect_HWevents=0
# Set to 1 when the CTRLC_Handler gets invoked.
handlerInvoked=0
# Log file
declare logFile
logFilePrefix='/tmp/perfcollect'
logEnabled=0
# Collect info to pass between processes
collectInfoFile=$(dirname `mktemp -u`)/'perfcollect.sessioninfo'
######################################
## Logging Functions
######################################
LogAppend()
{
if (( $logEnabled == 1 ))
then
echo $* >> $logFile
fi
}
RunSilent()
{
if (( $logEnabled == 1 ))
then
echo "Running \"$*\"" >> $logFile
$* >> $logFile 2>&1
echo "" >> $logFile
else
$* > /dev/null 2>&1
fi
}
RunSilentBackground()
{
if (( $logEnabled == 1 ))
then
echo "Running \"$*\"" >> $logFile
$* >> $logFile 2>&1 & sleep 1
echo "" >> $logFile
else
$* > /dev/null 2>&1 & sleep 1
fi
# When handler is invoked, kill the process.
pid=$!
for (( ; ; ))
do
if [ "$handlerInvoked" == "1" ]
then
kill -INT $pid
break;
else
sleep 1
fi
done
# Wait for the process to exit.
wait $pid
}
InitializeLog()
{
# Pick the log file name.
logFile="$logFilePrefix.log"
while [ -f $logFile ];
do
logFile="$logFilePrefix.$RANDOM.log"
done
# Mark the log as enabled.
logEnabled=1
# Start the log
date=`date`
echo "Log started at ${date}" > $logFile
echo '' >> $logFile
# The system information.
LogAppend 'Machine info: ' `uname -a`
if [ "$perfcmd" != "" ]
then
LogAppend 'perf version:' `$perfcmd --version 2>&1`
fi
if [ "$lttngcmd" != "" ]
then
LogAppend 'LTTng version: ' `$lttngcmd --version`
fi
LogAppend
}
CloseLog()
{
LogAppend "END LOG FILE"
LogAppend "NOTE: It is normal for the log file to end right before the trace is actually compressed. This occurs because the log file is part of the archive, and thus can't be written anymore."
# The log itself doesn't need to be closed,
# but we need to tell the script not to log anymore.
logEnabled=0
}
######################################
## Helper Functions
######################################
##
# Console text color modification helpers.
##
RedText()
{
tput=`GetCommandFullPath "tput"`
if [ "$tput" != "" ]
then
$tput setaf 1
fi
}
GreenText()
{
tput=`GetCommandFullPath "tput"`
if [ "$tput" != "" ]
then
$tput setaf 2
fi
}
BlueText()
{
tput=`GetCommandFullPath "tput"`
if [ "$tput" != "" ]
then
$tput setaf 6
fi
}
YellowText()
{
tput=`GetCommandFullPath "tput"`
if [ "$tput" != "" ]
then
$tput setaf 3
fi
}
ResetText()
{
tput=`GetCommandFullPath "tput"`
if [ "$tput" != "" ]
then
$tput sgr0
fi
}
# $1 == Status message
WriteStatus()
{
LogAppend $*
BlueText
echo $1
ResetText
}
# $1 == Message.
WriteWarning()
{
LogAppend $*
YellowText
echo $1
ResetText
}
# $1 == Message.
FatalError()
{
RedText
echo "ERROR: $1"
ResetText
PrintUsage
exit 1
}
EnsureRoot()
{
# Warn non-root users.
if [ `whoami` != "root" ]
then
RedText
echo "This script must be run as root."
ResetText
exit 1;
fi
}
######################################
# Command Discovery
######################################
DiscoverCommands()
{
perfcmd=`GetCommandFullPath "perf"`
if [ "$(IsDebian)" == "1" ]
then
# Test perf to see if it successfully runs or fails because it doesn't match the kernel version.
$perfcmd --version > /dev/null 2>&1
if [ "$?" == "1" ]
then
perfoutput=$($perfcmd 2>&1)
if [ $? -eq 1 ]
then
perfMarker="perf_"
if [[ "$perfoutput" == *"$perfMarker"* ]]
then
foundWorkingPerf=0
WriteWarning "Perf is installed, but does not exactly match the version of the running kernel."
WriteWarning "This is often OK, and we'll try to workaround this."
WriteStatus "Attempting to find a working copy of perf."
# Attempt to find an existing version of perf to use.
# Order the search by newest directory first.
baseDir="/usr/bin"
searchPath="$baseDir/perf_*"
for fileName in $(ls -d --sort=time $searchPath)
do
$($fileName > /dev/null 2>&1)
if [ $? -eq 1 ]
then
# If $? == 1, then use this copy of perf.
perfcmd=$fileName
foundWorkingPerf=1
break;
fi
done
if [ $foundWorkingPerf -eq 0 ]
then
FatalError "Unable to find a working copy of perf. Try re-installing via ./perfcollect install."
fi
WriteStatus "...FINISHED"
fi
fi
fi
fi
# Check to see if perf is installed, but doesn't exactly match the current kernel version.
# This happens when the kernel gets upgraded, or when running inside of a container where the
# host and container OS versions don't match.
perfoutput=$($perfcmd 2>&1)
if [ $? -eq 2 ]
then
# Check the beginning of the output to see if it matches the kernel warning.
warningText="WARNING: perf not found for kernel"
if [[ "$perfoutput" == "$warningText"* ]]
then
foundWorkingPerf=0
WriteWarning "Perf is installed, but does not exactly match the version of the running kernel."
WriteWarning "This is often OK, and we'll try to workaround this."
WriteStatus "Attempting to find a working copy of perf."
# Attempt to find an existing version of perf to use.
# Order the search by newest directory first.
baseDir="/usr/lib/linux-tools"
searchPath="$baseDir/*/"
for dirName in $(ls -d --sort=time $searchPath)
do
candidatePerfPath="$dirName""perf"
$($candidatePerfPath > /dev/null 2>&1)
if [ $? -eq 1 ]
then
# If $? == 1, then use this copy of perf.
perfcmd=$candidatePerfPath
foundWorkingPerf=1
break;
fi
done
if [ $foundWorkingPerf -eq 0 ]
then
FatalError "Unable to find a working copy of perf. Try re-installing via ./perfcollect install."
fi
WriteStatus "...FINISHED"
fi
fi
lttngcmd=`GetCommandFullPath "lttng"`
zipcmd=`GetCommandFullPath "zip"`
unzipcmd=`GetCommandFullPath "unzip"`
}
GetCommandFullPath()
{
echo `command -v $1`
}
######################################
# Prerequisite Installation
######################################
IsMariner()
{
local mariner=0
if [ -f /etc/lsb-release ]
then
local flavor=`cat /etc/lsb-release | grep DISTRIB_ID`
if [ "$flavor" == "DISTRIB_ID=\"Mariner\"" ]
then
mariner=1
fi
fi
echo $mariner
}
InstallPerf_Mariner()
{
# Disallow non-root users.
EnsureRoot
# Install perf
tdnf install -y kernel-tools
# Install zip and unzip
tdnf install -y zip unzip
}
IsAlpine()
{
local alpine=0
local apk=`GetCommandFullPath "apk"`
if [ "$apk" != "" ]
then
alpine=1
fi
echo $alpine
}
InstallPerf_Alpine()
{
# Disallow non-root users.
EnsureRoot
# Install perf
apk add perf --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
# Install zip and unzip
apk add zip unzip
}
IsRHEL()
{
local rhel=0
if [ -f /etc/redhat-release ]
then