Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
summarize_stats.cpython-314.pyc503 linesDownload Raw Back to __pycache__
1+
2��i����>a�0t$Rt^RIHt^RIt^RIt^RIHt^RIH	t	^RI3Ht^RIt^RI
t
^RIt^RIt^RIHt^RIt^RIHt^RIt^RIt^RIt^RIHtHtHtHt]]]3,tR	] R4&]!]",t#R	] R&]"]R3,t$R	] R
&]R.]#3,t%R	] R&]PLR8XdRt'MRt']!](4PR^,t*RLt+RRlt,Rt-RRlt.RRlt/]	!RR7!RR44t0!RR]14t2]	!RR7!R R!44t3!R"R#]34t4!R$R%4t5!R&R4t6!R'R(]Pn4t8!R)R*4t9!R+R,4t:R-R.lt;R/R0lt<RMR1R2llt=R3R4lt>R5R6lt?R7R8lt@R9R:ltAR;R<ltBR=R>ltCR?R@ltDRARBltERCRDltF]<!4]=!RE4]>!4]?!4]@!4]A!4]B!4]C!4]D!4]E!4]F!4.tGRNRFRGlltH]R,3RHRIlltIRJtJ]KRK8Xd5]J!4R#R#)OzTPrint a summary of specialization stats for all files in the6default stats folders.7)�annotationsN)�KeysView)�	dataclass)�date)�8itemgetter)�Path)�Any�Callable�TextIO�	TypeAliasr�RawData�Rows.�Columns�Stats�
RowCalculator�ntzc:\temp\py_stats\z/tmp/py_stats/c� �V^8�dQhRRRR/#)��name�str�return�)�formats"� Tools\scripts\summarize_stats.py�__annotate__r2s��*�*��*��*�c�B�VPRR4P4#)�_� )�replace�lower)rs&r�prettyr!2s���<�<��S�!�'�'�)�)rc9���RRRllp^RIpRVPP4Uu.uFpRV9gKVNK	upRV!\R4R,R	,R104RV!\R4R
,4/#uupi)�	SPEC_FAILc� �V^8�dQhRRRR/#)r�filepathr�prefixrr)rs"rr�0_load_metadata_from_source.<locals>.__annotate__7s����d��C�rc���\\V,4;_uu_4p\P!\4pRV,R,pVF�pVP4pVP
V4'gK,V\V4RpVP4wrgV\VP44,PVP44K�	RRR4V# +'giX#;i)z#define rN)�open�11SOURCE_DIR�collections�defaultdict�list�strip�12startswith�len�split�int�append)r%r&�spec_src�defines�start�liner�vals&&      r�get_defines�/_load_metadata_from_source.<locals>.get_defines7s���
�*�x�'�
(�
(�H�!�-�-�d�3�G���'�#�-�E� ���z�z�|�����u�-�-���C��J�L�)�� �J�J�L�	����C�I�I�K�(�)�0�0�����>�
!�)���)�
(���s�B:C#�#C4	N�_specialized_instructions�__�_stats_defines�Include�cpythonz	pystats.h�	EVAL_CALL�_defines�Pythonzspecialize.c)r#)�opcode�_specialized_opmap�keysr)r9rC�ops   r�_load_metadata_from_sourcerG6s�����	$��2�2�7�7�9�&13�9�2�T��^�B�B�9�&14�	�+���O�i�'�+�5�{�15�	�K��X��� ?�@����&16s17�	A:�A:c� �V^8�dQhRRRR/#)r�inputrrrr)rs"rrrQs��$E�$E��$E�'�$Erc���VP4'd�\VR4;_uu_4p\P!V4pRRR4XR,P	4UUu/uFwr4\V4VbK	uppVR&VR,P	4UUu/uFwr4\V4VbK	uppVR&V#VP
4'Ed\P\,!4pVP4F�p\V4;_uu_4pVFwpVPR4wr�TP#R4'dTR	,R188wdRTR,,pYXP4;;,\T	4,
uu&Ky	RRR4VR
;;,^,
uu&K�	\%V4pVP'\)44V#\VR24h +'giEL�;iuuppiuuppi \d5\RTP4RT2\P R7EK.i;i +'giL�;i)�rNr=rA�:zUnparsable line: 'z' in ��filezuops[:��Nrzuops[_:rONN�19__nfiles__z  is not a file or directory path)�is_filer)�json�load�itemsr2�is_dirr+�Counterr�iterdirr1�20ValueError�printr.�sys�stderrr/�dict�updaterG)21rI�fd�data�k�v�stats�filenamer7�key�values22&         r�
load_raw_datargQs����}�}���
�%��
�
���9�9�R�=�D��9=�=M�8N�8T�8T�8V�!W�8V���#�a�&�!�)�8V�!W��
��26�z�2B�2H�2H�2J�K�2J�$�!�C��F�A�I�2J�K��Z����	������#�#�C�(�*���
�
��H��h���2��D�!�%)�Z�Z��_�23���~�~�g�.�.�3�s�8�s�?�&��R��0���)�)�+�&�#�e�*�4�&�� �
�,��1�$��!(�$�E�{�����.�0�1����E�7�"B�C�D�D�E�
�
��"X��K��&�!��0������e�H�:�N�!$����!�!��	 ��sN�G,�$H�H�I� H�3I�24A
I�,G=	�:I�I�25I�I�Ic� �V^8�dQhRRRR/#)rr`r�json_outputr26r)rs"rrrxs��!�!��!�f�!rc�2�\P!W4R#�N)rS�dump)r`ris&&r�
save_raw_datarmxs���I�I�d� rT)�frozenc�8�]tRt^|t$R]R&R]R&RRltRtR#)�Docr�text�docc��V^8�dQhRR/#�rrrr)rs"rr�Doc.__annotate__�s��2728�2930�#�3132rc	�d�\P!RVPRVPR24#)z
33            uG34            <details>35            <summary>ⓘ</summary>36 37            z$38            </details>39            )�textwrap�dedentrqrr��selfs&r�markdown�Doc.markdown�s;�����
�
�Y�Y�K�
��X�X�J�
�
�	40�		41rrN)�__name__�42__module__�__qualname__�__firstlineno__�__annotations__r{�__static_attributes__rrrrprp|s��43
�I�	�H�4445�4647rrpc�"�]tRt^�tRRltRtR#)�Countc��V^8�dQhRR/#rtr)rs"rr�Count.__annotate__�s��"�"�#�"rc	��\VR4#)�,d)rrys&rr{�Count.markdown�s���d�D�!�!rrN)r}r~rr�r{r�rrrr�r��s��"�"rr�c�P�]tRt^�t$R]R&RtR]R&RtR]R&R	tR48RltRt	R#)
�Ratior2�numNz49int | None�denT�bool�50percentagec	��VP^8XdR#VPf
VP#VPVP,#)�g)r�r�rys&r�	__float__�Ratio.__float__�s6���8�8�q�=��
�X�X�
��8�8�O��8�8�d�h�h�&�&rc��V^8�dQhRR/#rtr)rs"rr�Ratio.__annotate__�s��512�522�#�532rc	�*�VPfR#VP^8Xd$VP^8wdVPR
R2#R#VP'd VPVP,R
#VPVP,R
#)N��,z / 0 !!z,.01%z,.02f)r�r�r�rys&rr{�Ratio.markdown�st���8�8���
�X�X��]��x�x�1�}��(�(�1��W�-�-��
�_�_�_��h�h����)�%�0�1��h�h����)�%�0�1rr)54r}r~rr�r�r�r�r�r{r�rrrr�r��s*��	�H��C����J���'�552�562rr�c�.a�]tRt^�tRV3RlltRtV;t#)�	DiffRatioc� �V^8�dQhRRRR/#)r�basez	int | str�headr)rs"rr�DiffRatio.__annotate__�s��0�0�Y�0�i�0rc	�<�\V\4'g\V\4'd\SV`
^^4R#\SV`
W!,57V4R#�r�N)�58isinstancer�super�__init__)rzr�r��	__class__s&&&�rr��DiffRatio.__init__�s<����d�C� � �J�t�S�$9�$9��G��Q��"��G��T�[�$�/rr)r}r~rr�r�r��
__classcell__)r�s@rr�r��s
���0�0rr�c��]tRt^�tRtRRltRRltRRltRR	ltR59Rlt	]60PRR
l4tRRlt
RRltRRltRRltRRltRRltRRltRRltRRltR R!ltR"R#ltR$R%ltR&R'ltR(tR)#)*�OpcodeStatszw61Manages the data related to specific set of opcodes, e.g. tier1 (with prefix62"opcode") or tier2 (with prefix "uops").63c��V^8�dQhRR/#)rr`zdict[str, Any]r)rs"rr�OpcodeStats.__annotate__�s��B�B�^�Brc	�*�WnW nW0nR#rk��_datarAr;)rzr`r5�specialized_instructionss&&&&rr��OpcodeStats.__init__�s���64��
�)A�&rc��V^8�dQhRR/#)rrz
KeysView[str]r)rs"rrr��s��!�!�-�!rc	�6�VPP4#rk)r�rErys&r�get_opcode_names�OpcodeStats.get_opcode_names�s���z�z��� � rc��V^8�dQhRR/#)rrzdict[tuple[str, str], int]r)rs"rrr��s����!;�rc	�"�/pVPP4Fnwr#VP4FUwrEV'gKVPR4'gK(V\R4^,RP	R4wppWQW&3&KW	Kp	V#)�65pair_countN�])r�rUr/r0�	partition)rz�pair_counts�name_i�opcode_statrerf�name_jrs&       r�get_pair_counts�OpcodeStats.get_pair_counts�s�����#'�:�:�#3�#3�#5��F�)�/�/�1�66���5�S�^�^�L�9�9�#&�s�<�'8�1�'<�'>�#?�#I�#I�#�#N�L�F�A�q�49�� 0�1�2�$6�67�rc��V^8�dQhRR/#)rrr2r)rs"rrr��s��M�M�3�Mrc	�V�\RVPP444#)c3�D"�TFqPR^4x�K	R#5i)�execution_countN��get��.0�xs& r�	<genexpr>�8OpcodeStats.get_total_execution_count.<locals>.<genexpr>�s���L�8K�1�5�5�*�A�.�.�8K�s� )�sumr��valuesrys&r�get_total_execution_count�%OpcodeStats.get_total_execution_count�s ���L��68�69�8I�8I�8K�L�L�Lrc��V^8�dQhRR/#�rrzdict[str, tuple[int, int]]r)rs"rrr��s��	�	�&@�	rc	��/pVPP4F7wr#RV9gKVR,p^pRV9dVPR^4pWE3W&K9	V#)r��
specializable�specialization.miss�r�rUr�)rz�countsrr��count�misss&     r�get_execution_counts� OpcodeStats.get_execution_counts�sb����!%���!1�!1�!3��D� �K�/�#�$5�6����"�+�5�&�?�?�+@�!�D�D� %�}���
"4��
rc��V^8�dQhRR/#)rrzEtuple[dict[str, collections.Counter], dict[str, collections.Counter]]r)rs"rrr��s��(�(�	N�(rc	�0�VP4p\P!\P4p\P!\P4pVP	4F(wwrEpV'gKWbV,V&WcV,V&K*	W#3#rk)r�r+r,rWrU)rzr��predecessors�70successors�first�secondr�s&      r�_get_pred_succ�OpcodeStats._get_pred_succ�s����*�*�,��7B�7N�7N����871��6A�5L�5L����672�73�'2�&7�&7�&9�"�O�U�U��u�.3�V�$�U�+�,1�5�!�&�)�':�74�'�'rc� �V^8�dQhRRRR/#�rrCrrzcollections.Counter[str]r)rs"rrr��s��0�0�s�0�/G�0rc	�>�VP4^,V,#�r��r��rzrCs&&r�get_predecessors�OpcodeStats.get_predecessors�����"�"�$�Q�'��/�/rc� �V^8�dQhRRRR/#r�r)rs"rrr��s��0�0�S�0�-E�0rc	�>�VP4^,V,#)�r�r�s&&r�get_successors�OpcodeStats.get_successors�r�rc� �V^8�dQhRRRR/#�rrCrr�dict[str, int]r)rs"rrr��s��"�"�C�"�N�"rc	�(�VPV,#rk�r�r�s&&r�_get_stats_for_opcode�!OpcodeStats._get_stats_for_opcode�s���z�z�&�!�!rc� �V^8�dQhRRRR/#�rrCrrr2r)rs"rrr��s��@�@�s�@�s�@rc	�Xa�VPV4o\V3Rl\44#)c3�H<"�TFpSPV^4x�K	R#5ir�r�)r��kind�family_statss& �rr��7OpcodeStats.get_specialization_total.<locals>.<genexpr>�s!����?���<�#�#�D�!�,�,��s�")r�r��TOTAL)rzrCr�s&&@r�get_specialization_total�$OpcodeStats.get_specialization_total�s$����1�1�&�9���?��?�?�?rc� �V^8�dQhRRRR/#r�r)rs"rrr��s�������rc	�H�VPV4p/p\VP44FqwrEVPR4'd0V\	R4RpVR9gVPR4'dKJM"VR9gVPR4'dKkTpWSV&Ks	V#)�specialization.N�
failure_kinds�pair)�success�failure)r�r�)r��sortedrUr/r0)rzrCr��resultrerf�labels&&     r�get_specialization_counts�%OpcodeStats.get_specialization_counts�s����1�1�&�9���� ��!3�!3�!5�6�J�C��~�~�/�0�0��C� 1�2�4�5���2�2�e�6F�6F��6W�6W��7X��������'�'����!�5�M�7��
rc� �V^8�dQhRRRR/#r�r)rs"rrr�s�������rc	��VPV4p/pRF'pV\R4RpVPV^4pWcV&K)	V#)�specialization.successrN)r�specialization.failure)r�r0r�)rzrCr�r	rer75r8s&&     r�"get_specialization_success_failure�.OpcodeStats.get_specialization_success_failuresU���1�1�&�9����G�C���-�.�0�1�E��"�"�3��*�C��5�M�H��
rc� �V^8�dQhRRRR/#r�r)rs"rrr�s��S�S�s�S�s�Src	�D�VPV4PR^4#)r)r�r�r�s&&r� get_specialization_failure_total�,OpcodeStats.get_specialization_failure_totals"���)�)�&�1�5�5�6N�PQ�R�Rrc� �V^8�dQhRRRR/#r�r)rs"rrr�s��$76�$77�s�$78�~�$79rc	�a�RV3RllpSPV4pRp^pVF-pVPR4'gK\WT!V44pK/	^.V^,,pVF,pVPR4'gKW6,Wt!V4&K.	\V4UU	u/uFwr�V	'gKV!W�4V	bK	up	p#uup	pi)c� �V^8�dQhRRRR/#)rr�r2rCrr)rs"rr�BOpcodeStats.get_specialization_failure_kinds.<locals>.__annotate__s��	'�	'�s�	'�C�	'rc�<�V^8:d$\SPV,^,4#VR8XdRpM=VPR4'dRpM#VR9dRpMVPR4'dRpSPV,F:pVPV4'gK\V\	V4^,R4u#	R\V4,#)	��LOAD_SUPER_ATTR�SUPER�ATTR�ITER�SUBSCRNzkind )�FOR_ITER�GET_ITER�SEND)r!rA�endswithr/r0r)r�rCrrzs&& �r�kind_to_text�BOpcodeStats.get_specialization_failure_kinds.<locals>.kind_to_texts�����q�y��d�m�m�D�1�!�4�5�5��*�*� ������(�(����;�;�������*�*�!���
�
�d�+�+���?�?�6�*�*�!�$�s�6�{�Q��'8�"9�:�:�,��S��Y�&�&rc�J�\VRRPR4^,4#)N�[�����)r2r1)res&r�key_to_index�BOpcodeStats.get_specialization_failure_kinds.<locals>.key_to_index.s!���s�3�B�x�~�~�c�*�1�-�.�.rzspecialization.failure_kind)r�r/�max�	enumerate)80rzrCr&r�r+�	max_indexrer�indexrfs81f&        r� get_specialization_failure_kinds�,OpcodeStats.get_specialization_failure_kindss����	'�	'� �1�1�&�9��	/��	��C��~�~�;�<�<��	�<��+<�=�	� ���y�1�}�-�
��C��>�>�"?�@�@��/;�/@�M�,�s�+�,� �#,�M�":�82�":����
/�L��'��.�":�83�	84��85s�%C�6
Cc� �V^8�dQhRRRR/#)rrCrrr�r)rs"rrr�As��E�E�s�E�t�Erc	�*�RVPV49#)r�)r�r�s&&r�is_specializable�OpcodeStats.is_specializableAs���$�"<�"<�V�"D�D�Drc��V^8�dQhRR/#)rrztuple[int, int, int]r)rs"rrr�Ds��L�L�.B�Lrc	�,�^p^p^p^pVPP4FkwrVRV9dKVR,pRV9dWG,
pK(WPP9d,VPR^4pW'V,86,
pW8,
pKcW,
pKm	WW43#)r�r�r�r�)r�rUr;r�)	rz�basic�specialized_hits�specialized_misses�not_specializedrCr�r�r�s	&        r�get_specialized_total_counts�(OpcodeStats.get_specialized_total_countsDs�����������#'�:�:�#3�#3�#5��F� ��3��� 1�2�E��+�-��(���9�9�9�"���'<�a�@�� �D�L�0� �"�*�"����$6��(:�K�Krc��V^8�dQhRR/#�rrr�r)rs"rrr�Ws��87�88�^�89rc		��VPP4UUu/uF wrVR8wgKWPR^4bK"	upp#uuppi)�RESUMEzspecialization.deferredr��rzrCr�s&  r�get_deferred_counts�OpcodeStats.get_deferred_countsWsS��(,�z�z�'7�'7�'9�90�'9�#����!�
B�F�O�O�$=�q�A�A�'9�91�	92��93s94�A�Ac��V^8�dQhRR/#r@r)rs"rrr�^s��95�96�>�97rc		��VPP4UUu/uF0wrVPV4'dKWPR^4bK2	upp#uuppi)r�)r�rUr5r�rCs&  r�get_misses_counts�OpcodeStats.get_misses_counts^sX��(,�z�z�'7�'7�'9�98�'9�#���(�(��0�
>�F�O�O�$9�1�=�=�'9�99�	100��101s102�A�Ac��V^8�dQhRR/#r@r)rs"rrr�es����>�rc	��/pVPP4F%wr#VPR^4pV'gK!WAV&K'	V#)r�r�)rzr�rC�entryr�s&    r�get_opcode_counts�OpcodeStats.get_opcode_countsesC����!�Z�Z�-�-�/�M�F��I�I�g�q�)�E��u�!&�v��0��
rr�N)r}r~rr��__doc__r�r�r�r�r��	functools�cacher�r�r�r�r�rrrr1r5r=rDrHrMr�rrrr�r��s����103B�104!��M�	��_�_�(��(�$0�0�"�@��(�S�$105�LE�L�&106�107��rr�c��]tRtRtRRltRRlt]PRRl4tRR	lt	R108Rlt109RR
ltRRltRRlt
RRltRRltRRltRtR#)rinc��V^8�dQhRR/#)rr`rr)rs"rr�Stats.__annotate__os����W�rc	��WnR#rkr�)rzr`s&&rr��Stats.__init__os���110rc� �V^8�dQhRRRR/#)rrerrr2r)rs"rrrTrs��&�&�s�&�s�&rc	�:�VPPV^4#r�)r�r�)rzres&&rr��	Stats.getrs���z�z�~�~�c�1�%�%rc� �V^8�dQhRRRR/#)rr&rrr�r)rs"rrrTvs��111�112�s�113�{�114rc	��\P\\3,!\4pVPP4F_wr4VP
V4'gKV\V4^,RPR4wrVpWBV,VPR4&Ka	\VVPR,VPR,4#)r�Nr��.rAr;)r+r,rr]r�rUr/r0r�r.r�)rzr&�opcode_statsrerfrr�rests&&      r�get_opcode_stats�Stats.get_opcode_statsus���"�.�.�s�D�y�9�$�?���*�*�*�*�,�J�C��>�>�&�)�)����F��a�� 1�2�<�<�S�A�M�D�T�27���t�z�z�#��/�	-�115���J�J�z�"��J�J�2�3�116�	117rc��V^8�dQhRR/#r@r)rs"rrrT�s�����rc		���VPR,p/p\VPP44Fmwr4RV9dWBV&KVPR4'gK+VRRP	R4wrVVR\V\
V4,^,4R2pWBV&Ko	\VPP44F"wr4VPR4'gKWBV&K$	V#)	r=�Calls tozCalls Nr)z (�)�Framer*)r�rrUr/r1r!r2)rzr5r	rerfrr0r118s&       r�get_call_stats�Stats.get_call_stats�s����*�*�-�.���� ����!1�!1�!3�4�J�C��S� �#�s������)�)�!�#�2�h�n�n�S�1����&��6�'�#�e�*�*=�a�*@�#A�"B�!�D�� %�u�
�
5�!����!1�!1�!3�4�J�C��~�~�g�&�&�#�s��5��
rc��V^8�dQhRR/#r�r)rs"rrrT�s��"�"�"<�"rc	��VPPR^4pVPPR^4VPPR^4,pVPPR^4VPPR^4,VPPR^4,VPPR^4,pVPPR^4VPPR^4,VPPR	^4,VPPR119^4,p/pVPP4F�wrgVPR4'gKRV9dTpM R
V9dTpMRV9dTpMRV9dTpMRpVR,P	4p	V	^,P4V	R,,p	Wx3WY&K�	V#)zObject inline valueszObject allocationsz Object allocations from freelistz!Object interpreter mortal increfszObject mortal increfsz#Object interpreter immortal increfszObject immortal increfsz!Object interpreter mortal decrefszObject mortal decrefsz#Object interpreter immortal decrefszObject immortal decrefs�Object�materialize�allocations�increfs�decrefsN:rPNN�r�NN)r�r�rUr/r.�upper)120rz�total_materializations�total_allocations�
total_increfs�
total_decrefsr	rerfr�r121s122&         r�get_object_stats�Stats.get_object_stats�s���!%�����0F��!J�� �J�J�N�N�+?��C�d�j�j�n�n�.��G123�124��
�J�J�N�N�>��B��J�J�N�N�2�A�6�
7��J�J�N�N�@�!�D�
E�
�J�J�N�N�4�a�8�
9�	�
�J�J�N�N�>��B��J�J�N�N�2�A�6�
7��J�J�N�N�@�!�D�
E�
�J�J�N�N�4�a�8�
9�	����*�*�*�*�,�J�C��~�~�h�'�'� �C�'�0�C�"�c�)�+�C��#�%�'�C��#�%�'�C��C��B��
�
����a����(�5��9�4��!&���
�-��
rc��V^8�dQhRR/#)rrzlist[dict[str, int]]r)rs"rrrT�s����2�rc	�J�.pVPP4F�wr#VPR4'gKVR,PR4wrEpVP	4p\V4p\
V4V8:dVP/4K#W1V,V&K�	V#)�GC:�NNr�)r�rUr/r�r.r2r0r3)	rz�gc_statsrerf�nrr^r�gen_ns	&        r�get_gc_stats�Stats.get_gc_stats�s���)+���*�*�*�*�,�J�C��>�>�$�'�'���R��*�*�3�/�J�A�$��:�:�<�D���F�E��h�-�5�(�����#�$)�U�O�D�!�-��rc��V^8�dQhRR/#�rrz!dict[str, tuple[int, int | None]]r)rs"rrrT�s��L125�L126�(I�L127rc	�r�RVP9d/#VPR,pVPR,pVPR,pVPR,pVPR,pVPR,pVPR,pVPR,pVPR,p	VPR	,p128VPR129,pVPR,pVPR,p
\RR
4VR3\RR4W!3\RR4WQ3\RR4Wa3\RR4Wq3\RR4W�3\RR4W�3\RR4W�3\RR4W�3\RR 4W�3\RR!4W�3\R"R#4VR3\R$R%4VV3/
#)&zOptimization attempts�Optimization traces created�Optimization traces executedzOptimization uops executedz!Optimization trace stack overflowz"Optimization trace stack underflowzOptimization trace too longzOptimization trace too shortzOptimization inner loopzOptimization recursive callzOptimization low confidencezOptimization unknown calleezExecutors invalidatedz�The number of times a potential trace is identified.  Specifically, this occurs in the JUMP BACKWARD instruction when the counter reaches a threshold.NzTraces createdz4The number of traces that were successfully created.zTrace stack overflowzGA trace is truncated because it would require more than 5 stack frames.zTrace stack underflowzJA potential trace is abandoned because it pops more frames than it pushes.zTrace too longzFA trace is truncated because it is longer than the instruction buffer.zTrace too shortz7A potential trace is abandoned because it is too short.zInner loop foundz1A trace is truncated because it has an inner loopzRecursive callz5A trace is truncated because it has a recursive call.zLow confidencezVA trace is abandoned because the likelihood of the jump to top being taken is too low.zUnknown calleez=A trace is abandoned because the target of a call is unknown.zPThe number of executors that were invalidated due to watched dictionary changes.zTraces executedz'The number of traces that were executed�
Uops executedz>The total number of uops (micro-operations) that were executed�r�rp)rz�attempts�created�executed�uops�trace_stack_overflow�trace_stack_underflow�trace_too_long�trace_too_short�130inner_loop�recursive_call�low_confidence�unknown_callee�executors_invalidateds&             r�get_optimization_stats�Stats.get_optimization_stats�s��"�$�*�*�4��I��:�:�5�6���*�*�:�;���:�:�<�=���z�z�6�7��#�z�z�*M�N�� $�131�132�+O� P�����$A�B���*�*�%C�D���Z�Z� 9�:�133����$A�B�����$A�B�����$A�B�� $�134�135�+B� C��
�'��
�136�$��� �"X�
��"��&�Y�
�%�/��'�\�
�&�0�� �X�
��)��!�I�
� �*��"�$W�
��%�� �G�
��)�� ��
��)�� �O�
��)��'�&�
�&�/��!�#L�M���P�
��P�
����m:137�:	138rc��V^8�dQhRR/#r�r)rs"rrrTs��139�140�%F�141rc	�H�VPR,pVPR,pVPR,pVPR,pVPR,p\RR4VR3\RR	4W!3\R142R4W13\RR
4WA3\RR4WQ3/#)zOptimization optimizer attemptsz Optimization optimizer successesz(Optimization optimizer failure no memoryz)Optimizer remove globals builtins changedz'Optimizer remove globals incorrect keyszOptimizer attemptszOThe number of times the trace optimizer (_Py_uop_analyze_and_optimize) was run.NzOptimizer successesz6The number of traces that were successfully optimized.zOptimizer no memoryz9The number of optimizations that failed due to no memory.zRemove globals builtins changedz(The builtins changed during optimizationzRemove globals incorrect keysz;The keys in the globals dictionary aren't what was expectedr�)rzr��	successes�	no_memory�builtins_changed�incorrect_keyss&     r�get_optimizer_stats�Stats.get_optimizer_statss����:�:�?�@���J�J�A�B�	��J�J�I�J�	��:�:�&Q�R�����$M�N��
�$�a�
��$���%�H�
��$��%�K�
��$��1�:�
�!�+��/�M�
��)�)143�	144rc��V^8�dQhRR/#)rrz!dict[Doc, tuple[int, int | None]]r)rs"rrrT1s��!145�!146�&G�!147rc	��VPR,pVPR,pVPR,pVPR,pVPR,pVPR,p\RR4VR3\R	R1484W!3\RR4W13\R
R4WA3\RR4WQ3\RR4Wa3/#)zJIT total memory sizez
JIT code sizezJIT trampoline sizez
JIT data sizezJIT padding sizezJIT freed memory size�Total memory sizez9The total size of the memory allocated for the JIT tracesNz	Code sizez?The size of the memory allocated for the code of the JIT traceszTrampoline sizezFThe size of the memory allocated for the trampolines of the JIT tracesz	Data sizez?The size of the memory allocated for the data of the JIT traceszPadding sizezBThe size of the memory allocated for the padding of the JIT traceszFreed memory sizez0The size of the memory freed from the JIT tracesr�)rz�jit_total_memory_size�
jit_code_size�jit_trampoline_size�
jit_data_size�jit_padding_size�jit_freed_memory_sizes&      r�get_jit_memory_stats�Stats.get_jit_memory_stats1s��� $�149�150�+B� C���151�152�?�3�
�"�j�j�)>�?���153�154�?�3�
��:�:�&8�9�� $�155�156�+B� C��
�#�K�
�&�t�,���Q�
��5��!�X�
�$�;���Q�
��5���T�
�!�8��#�B�
�&�=�1157�	158rc� �V^8�dQhRRRR/#)rr&rrzlist[tuple[int, int]]r)rs"rrrTTs����C��,A�rc	��.pVPP4FWwr4\P!VR2V4pVfK%\	VP4^,4pVP
Wd34KY	VP4V#)z\[([0-9]+)\])r�rU�re�matchr2�groupsr3�sort)rzr&�rowsrarbr�rLs&&     r�
get_histogram�Stats.get_histogramTsp�����J�J�$�$�&�D�A��H�H��x�~�6��:�E�� ��E�L�L�N�1�-�.�����U�J�'�	'�159	
�	�	���rc��V^8�dQhRR/#)rrzlist[tuple[str, int]]r)rs"rrrT^s��160�161�!6�162rc	���RpVPP4UUu.uFEwr#VPV4'gKV\V4^,RP	RR4V3NKG	upp#uuppi)zRare event rrr*)r�rUr/r0r)rzr&rer8s&   r�get_rare_events�Stats.get_rare_events^sl����!�J�J�,�,�.�163�.����~�~�f�%�
?�S��V��q��2�
&�
.�
.�s�C�
8�#�>�.�164�	165��166s�A/�+A/r�N)r}r~rr�r�r�rPrQr_rfrur~r�r�r�r�r�r�rrrrrnsU���&��_�_�167��168��""�H�L169�\170�<!171�F�172�173rc�&�]tRtRt^t^t^t^tRtR#)�JoinModeigrN)	r}r~rr��SIMPLE�CHANGE�CHANGE_ONE_COLUMN�CHANGE_NO_SORTr�rrrr�r�gs��
�F��F����Nrr�c�t�]tRtRtRt]P3RRlltRRltRRlt	R	R174lt175RRR
lltRtR#)�Tableiuzo176A Table defines how to convert a set of Stats into a specific set of rows177displaying some aspect of the data.178c�$�V^8�dQhRRRRRR/#)r�column_namesr�	calc_rowsr�	join_moder�r)rs"rr�Table.__annotate__{s(��#�#��#�!�#��	#rc	�*�WnW nW0nR#rk)�columnsr�r�)rzr�r�r�s&&&&rr��Table.__init__{s��$��"��"�rc�(�V^8�dQhRRRRRRRR/#)rrer�row_a�tuple�row_brr)rs"rrr��s.��P�P�C�P��P�e�P��Prc	�|�VP;\P8Xd179V.VOVO5#;;\P8XdM;\P8XdMM$V.VOVO\V^,V^,4N5#\P8Xd,W^,V^,\V^,V^,43#R#r�)r�r�r�r�r�r�r�)rzrer�r�s&&&&r�join_row�Table.join_row�s����n�n� �����,�e�,�e�,�,�:�����#:�8�#:�#:�:��K�e�K�e�K�Y�u�Q�x��q��-J�K�K��+�+��1�X�u�Q�x��5��8�U�1�X�1N�O�O�,rc� �V^8�dQhRRRR/#)rr�rrr)rs"rrr��s����G���rc	���VP;\P8Xd-V^,.RVR,4ORVR,4O5#;;\P8XdM;\P8XdMM4V^,.RVR,4ORVR,4O5R180,#\P1818Xd*V^,RV^,,RV^,,R3#R	#)r�c3�4"�TFpRV,x�K	R#5i��Base Nrr�s& rr��%Table.join_columns.<locals>.<genexpr>�����7�;�a�g��k�k�;���roc3�4"�TFpRV,x�K	R#5i��Head Nrr�s& rr�r��r�r�c3�4"�TFpRV,x�K	R#5ir�rr�s& rr�r��r�r�c3�4"�TFpRV,x�K	R#5ir�rr�s& rr�r��r�r��Change:r�r�N)r�)r�r�r�r�r�r�)rzr�s&&r�join_columns�Table.join_columns�s����n�n� �����A�J��7�7�2�;�7��8�7�2�;�7���182;�����#:�8�#:�#:�:��A�J��7�7�2�;�7��8�7�2�;�7��!�	!�!�183�+�+��A�J��g�a�j�(��g�a�j�(��	��,rc�$�V^8�dQhRRRRRR/#)r�rows_ar
�rows_br�tuple[Columns, Rows]r)rs"rrr��s"����$����9M�rc	�6�\VP4pRV^,184,pVUu/uFqU^,VR,bK	ppVUu/uFqU^,VR,bK	pp\V4\V48wg\V4\V48wd\R4h\VP	44VP	4Uu.uF
q�V9gKVNK	up,p	V	Uu.uF3pVPW�P
W�4VP
W�44NK5	p185pVP\P\P39dV186PRRR7VPVP4pW�3#uupiuupiuupiuupi)r�rozDuplicate keysc�8�\\VR,44#)r�r*)�abs�float)�rows&r�<lambda>�#Table.join_tables.<locals>.<lambda>�s��c�%��B��.�&9rT�re�reverse)r�)
r0r�rYr-rEr�r�r�r�r�r�r�r�)rzr�r��ncols�defaultr��data_a�data_brarEr�r�s&&&         r�join_tables�Table.join_tables�sS���D�L�L�!���5�1�9�%��'-�.�v�!�A�$��"��+�v��.�'-�.�v�!�A�$��"��+�v��.��v�;�#�f�+�%��V���F��)C��-�.�.��F�K�K�M�"�����%R��A�6�/�a�a��%R�R���187���
�M�M�!�Z�Z��3�V�Z�Z��5K�L��	
�188��>�>�h�o�o�x�/I�/I�J�J��I�I�9�4�I�H��#�#�D�L�L�1���}���#/��.��&S��189s�F�	F�F�F�+9FNc�$�V^8�dQhRRRRRR/#)r�190base_statsr�191head_stats�Stats | Nonerr�r)rs"rrr��s$��192�193��194�-9�195�	�196rc	��Vf VPV4pVPV3#VPV4pVPV4pVPWE4wrcWc3#rk)r�r�r�)rzr�r�r�r�r��colss&&&    r�	get_table�Table.get_table�s]�����>�>�*�-�D��<�<��%�%��^�^�J�/�F��^�^�J�/�F��)�)�&�9�J�D��:�r)r�r�r�rk)
r}r~rr�rOr�r�r�r�r�r�r�r�rrrr�r�us/���'�o�o�	#�P��,�.197�198rr�c�6�]tRtRtRtRRRRR/RR	llltR199tR#)�Sectioni�z5200A Section defines a section of the output document.201r�N�comparativeTrrc�(�V^8�dQhRRRRRRRR/#)r�titler�summaryr�r�rrr)rs"rr�Section.__annotate__�s2��'�'��'��'��
'��'rc	�a�WnV'gVP4VnMW n\P!V4VnSf.o\
S\4'dRV3RllpW`nMSVnW@n	R#)Nc� �V^8�dQhRRRR/#�rr�rr�r�r)rs"rr�&Section.__init__.<locals>.__annotate__�s��
%�
%�u�
%�,�
%rc3�(<"�SRjx�L202R#L5irkr)r�r��	part_iters&&�r�203iter_parts�$Section.__init__.<locals>.iter_parts�s����$�$�$�s���)204r�r r�rwrxrrr�r-rr�)rzr�r�rr�rrrs&&&f$$ rr��Section.__init__�se����205�� �;�;�=�D�L�"�L��?�?�3�'������I��i��&�&�
%�
%�(�N�&�D�N�&�r)r�rrrr�r�)r�r�N)r}r~rr�rOr�r�rrrr�r��s%���'�!�
'��'�'rr�c� �V^8�dQhRRRR/#)rr&rrrr)rs"rrr�s����s��}�rc�a�RV3RllpV#)c� �V^8�dQhRRRR/#�rrcrrr
r)rs"rr�0calc_execution_count_table.<locals>.__annotate__�s����E��d�rc206�r<�VPS2074pVP4pVP4p^p.p\VP	4\^4RR7FWwpwrxWG,
pV'd
\
W�4p	MRp	VPV\V4\
Ws4\
WC4V	34KY	V#)r�Tr�N)	r_r�r�rrUrr�r3r�)rcr]r��total�208cumulativer�rCr�r��miss_valr&s&         �r�calc�(calc_execution_count_table.<locals>.calc�s�����-�-�f�5���2�2�4���6�6�8���209���%+��L�L�N�210�1�
�t�&211�!�F�M�U�
��J�� ��-�����K�K���%�L��%�'��*�,���
�&212�"�rr)r&rsf r�calc_execution_count_tabler�s�����2�Krc��V^8�dQhRR/#�rrr�r)rs"rrrs�����rc213�h�\RR\R\R4\PR7.RR7#)zExecution countsz)Execution counts for Tier 1 instructions.rC)r�z�214        The "miss ratio" column shows the percentage of times the instruction215        executed that it deoptimized. When this happens, the base unspecialized216        instruction is not counted.217        �rr��Name�Count:�Self:�Cumulative:zMiss ratio:)r�r�rr�r�rrr�execution_count_sectionrs;����3��I�*�8�4�"�4�4�
�	218�
��rc� �V^8�dQhRRRR/#)rr&rrr�r)rs"rrrs��$�$�s�$�7�$rc�ha�RV3Rllp\RRV'dTMSR2\RV4.RRR7#)	c� �V^8�dQhRRRR/#rr)rs"rr�(pair_count_section.<locals>.__annotate__s����U��t�rc219�x<�VPS	4pVP4pVP4p^p.p\P!\VP
4\^4RR7^d4FEwwrgpWH,
pVPVRV2\V4\W�4\WC434KG	V#)r�Tr�r)r_r�r��	itertools�islicerrUrr3r�r�)220rcr]r�rrr��opcode_i�opcode_jr�r&s221&        �r�calc_pair_count_table�1pair_count_section.<locals>.calc_pair_count_tables�����-�-�f�5��"�2�2�4���6�6�8���222���+4�+;�+;��;�$�$�&�J�q�M�4�H�#�,223�'� �X�%�
��J��K�K��j��(��,��%�L��%�'��*�,�	�
�	,224��rzPair countszPair counts for top 100 z pairsFz�225        Pairs of specialized operations that deoptimize and are then followed by226        the corresponding unspecialized instruction are not counted as pairs.227        �r�rr)�Pairrrr�r�r�)r&r�r'sf& r�pair_count_sectionr,sM�����*��228"�E�5�v�">�f�E��:�%�
�	229��
��rc��V^8�dQhRR/#rr)rs"rrr@s��.�.��.rc�2�RRRllp\RRVRRR7#)	Nc� �V^8�dQhRRRR/#rr)rs"rr�,pre_succ_pairs_section.<locals>.__annotate__As��"�"�u�"�,�"rc3�raa"�VeQhVPR4pVP4F�pVPV4pVPV4pVP	4pVP	4pV^8Xd230V^8XdKUVP^4UU	u.uFwr�V\
V	4\W�43NK	up	poVP^4U231U	u.uFwr�V232\
V	4\W�43NK	up	p233o\VRV2\RV3Rl4\RV3Rl4.4x�K�	R#uup	piuup	p234i5i)NrCz Successors and predecessors for c�<�S#rkr)r�	pred_rowss*�rr��Lpre_succ_pairs_section.<locals>.iter_pre_succ_pairs_tables.<locals>.<lambda>\����9rc�<�S#rkr)r�	succ_rowss*�rr�r4`r5r)�Predecessorsr�Percentage:)�235Successorsrr9)236r_r�r�r�r�most_commonr�r�r�r�)
r�r�r]rCr�r��predecessors_total�successors_total�predr��succr3r7s
&&         @@r�iter_pre_succ_pairs_tables�:pre_succ_pairs_section.<locals>.iter_pre_succ_pairs_tablesAsG�����!�!�!�!�2�2�8�<��"�3�3�5�F�'�8�8��@�L�%�4�4�V�<�J�!-�!3�!3�!5��)�/�/�1��!�Q�&�+;�q�+@��&2�%=�%=�a�%@��%@�M�T��u�U�|�U�5�%E�F�%@��I�&0�%;�%;�A�%>��%>�M�T��u�U�|�U�5�%C�D�%>��I�237��2�6�(�;��A�,���?�,��	�
�

�!6�����s�BD7�"D+�7D7�"D1�1AD7zPredecessor/Successor Pairsz8Top 5 predecessors and successors of each Tier 1 opcode.Fz�238        This does not include the unspecialized instructions that occur after a239        specialized instruction deoptimizes.240        r)rk�r�)r@s r�pre_succ_pairs_sectionrC@s(��"�H�%�B�"��
�	�	rc��V^8�dQhRR/#rr)rs"rrrqs��f�f��frc�`aaa�RRloRRloRRloR241RVVV3Rlllp\RR	V4#)c� �V^8�dQhRRRR/#)rrCrrrr)rs"rr�,specialization_section.<locals>.__annotate__rs����#��-�rc�a�RV3RllpV#)c� �V^8�dQhRRRR/#rr)rs"rr�Ospecialization_section.<locals>.calc_specialization_table.<locals>.__annotate__ss��	�	��	�$�	rc242�<�RRRRRRRR/pVPR4pVPS4pVPS4pVP4UUu.uF,wrV\	WQV,4\V4\
Wc43NK.	upp#uuppi)�deferredzLLists the number of "deferred" (i.e. not specialized) instructions executed.�hitz'Specialized instructions that complete.r�z$Specialized instructions that deopt.�deoptrC)r_r�rrUrpr�r�)rc�DOCSr]r�specialization_countsr243r�rCs&      �rr�Gspecialization_section.<locals>.calc_specialization_table.<locals>.calcss�����j��@��>��?�	�D�!�1�1�(�;�L� �9�9�&�A�E�$0�$J�$J�6�$R�!�%:�$?�$?�$A�
�%B�L�E�	��E�{�+��%�L��%�'��244%B�
�
��s�2Br)rCrsf r�calc_specialization_table�9specialization_section.<locals>.calc_specialization_tablers���	�	�*�rc� �V^8�dQhRRRR/#�rrrrrr)rs"rrrG�s������
�rc�a�RV3RllpV#)c� �V^8�dQhRRRR/#rr)rs"rr�_specialization_section.<locals>.calc_specialization_success_failure_table.<locals>.__annotate__�s��	�	��	�$�	rc245�$<�VPR4PS4p\VP44pV'dHVP	4UUu.uF*wr4VP4\
V4\WB43NK,	upp#.#uuppi)rC)r_rr�r�rU�246capitalizer�r�)rcr�rr247r8rs&    �rr�Wspecialization_section.<locals>.calc_specialization_success_failure_table.<locals>.calc�s�����+�+���0�0��6�
���
�
��(�E��'-�l�l�n��&4�248���%�%�'��s��U�3�5F�G�&4���249�	��s�0Br�rrsf r�)calc_specialization_success_failure_table�Ispecialization_section.<locals>.calc_specialization_success_failure_table�s���	�	��rc� �V^8�dQhRRRR/#rUr)rs"rrrG�s����S��]�rc�a�RV3RllpV#)c� �V^8�dQhRRRR/#rr)rs"rr�\specialization_section.<locals>.calc_specialization_failure_kind_table.<locals>.__annotate__�s��
	�
	��
	�$�
	rc�&<�VPR4pVPS4pVPS4p\VP	4UUu.uF&wrEV'gKV\V4\
WS43NK(	upp\^4RR7#uuppi)rCTr�)r_r1rrrUr�r�r)rcr]�failuresrr250rfrs&     �rr�Tspecialization_section.<locals>.calc_specialization_failure_kind_table.<locals>.calc�s���� �1�1�(�;�L�#�D�D�T�J�H� �A�A�$�G�E��)1���(8��(8����?�U�E�%�L�%��*=�>�(8��251�q�M���
��s�
B
252�B
253rr\sf r�&calc_specialization_failure_kind_table�Fspecialization_section.<locals>.calc_specialization_failure_kind_table�s���
	�
	��rc� �V^8�dQhRRRR/#rr)rs"rrrG�s��%�%�u�%�,�%rc
3�N<"�VPR4pVP4pVe)VPR4pW4P4,pMRp\V4F�pVPV4'gKVP	V4^8XdVeVP	V4^8XdKN\VRVR2\
RS!V4\P4\
RS!V4\P4\
RS!V4\P4.4x�K�	R#5i)rCNzspecialization stats for z family)�Kindr�Ratio:)�Successrrk)zFailure kindrrk)	r_r�rr5r�r�r�r�r�)	r�r��opcode_base_stats�names�opcode_head_statsrCrfr]rRs	&&    ���r�iter_specialization_tables�:specialization_section.<locals>.iter_specialization_tables�s����&�7�7��A��!�2�2�4���!� *� ;� ;�H� E���7�7�9�9�E� $���U�m�F�$�5�5�f�=�=�� �9�9�&�A�Q�F�!�)�$�=�=�f�E��J����+�F�8�7�;��4�1�&�9� ����254�7�A�&�I� ����255�<�>�v�F� ������
�$�s�D"D%zSpecialization statszSpecialization stats by familyrkrB)rprfr]rRs @@@r�specialization_sectionrrqs5����0� �$%�%�N��(�"��rc��V^8�dQhRR/#rr)rs"rrr�s��o�o�g�orc��RRlpRRlpRRlp\RR\RV\P4\RR	\RV\P4.4\R256R\RV\P4.4.RR
7#)c� �V^8�dQhRRRR/#rr)rs"rr�:specialization_effectiveness_section.<locals>.__annotate__�s��,257�,258�u�,259��,260rc	�r�VPR4pVP4pVP4wpppp\RR4\	V4\W243\RR4\	V4\Wb43\RR4\	V4\WB43\RR4\	V4\WR43.#)	rC�BasiczFInstructions that are not and cannot be specialized, e.g. `LOAD_FAST`.zNot specializedzTInstructions that could be specialized but aren't, e.g. `LOAD_ATTR`, `BINARY_SLICE`.zSpecialized hitsz@Specialized instructions, e.g. `LOAD_ATTR_MODULE` that complete.zSpecialized missesz=Specialized instructions, e.g. `LOAD_ATTR_MODULE` that deopt.)r_r�r=rpr�r�)rcr]rr9r:r;r<s&      r�'calc_specialization_effectiveness_table�Uspecialization_effectiveness_section.<locals>.calc_specialization_effectiveness_table�s����-�-�h�7���6�6�8��
�5�5�7�	261�����262��\���e���e�#�

��%�j���o�&��o�-�

��&�V���&�'��&�.�

��(�S���(�)��(�0�

�3!263�!	264rc� �V^8�dQhRRRR/#rr)rs"rrrv	s��265�266�e�267��268rc269�>�VPR4pVP4p\VP44pV^8Xd.#\	VP4\
^4RR7R,UUu.uFwrEV\V4\WS43NK	upp#uuppi�rCTr�:N�270N)	r_rDr�r�rrUrr�r�)rcr]�deferred_countsrrrfs&     r�calc_deferred_by_table�Dspecialization_effectiveness_section.<locals>.calc_deferred_by_table	s����-�-�h�7��&�:�:�<���O�*�*�,�-���A�:��I� &��%�%�'�Z��]�D� �� �271� ����5��<��u�!4�5� �272�	273��274��3"Bc� �V^8�dQhRRRR/#rr)rs"rrrvs��275�276�E�277�d�278rc279�>�VPR4pVP4p\VP44pV^8Xd.#\	VP4\
^4RR7R,UUu.uFwrEV\V4\WS43NK	upp#uuppir})	r_rHr�r�rrUrr�r�)rcr]�
misses_countsrrrfs&     r�calc_misses_by_table�Bspecialization_effectiveness_section.<locals>.calc_misses_by_tables����-�-�h�7��$�6�6�8�
��M�(�(�*�+���A�:��I� &��#�#�%�:�a�=�$� �� �280� ����5��<��u�!4�5� �281�	282��283r�zSpecialization effectivenessr�zDeferred by instructionzDBreakdown of deferred (not specialized) instruction counts by familyzMisses by instructionzEBreakdown of misses (specialized deopts) instruction counts by familyz~284        All entries are execution counts. Should add up to the total number of285        Tier 1 instructions executed.286        r)�Instructionsrrk)rrrk�r�r�r�r�)ryr�r�s   r�$specialization_effectiveness_sectionr��s���,287�\288�289��&�290��4�7����
�291
�)�V��4�.� �����292
�
�'�W��4�,� �����293
�#	294�:
�A$�$rc��V^8�dQhRR/#rr)rs"rrrLs����G�rc	�`�RRlp\RR\RV\P4.RR7#)c� �V^8�dQhRRRR/#rr)rs"rr�(call_stats_section.<locals>.__annotate__Ms��295�296�U�297�t�298rc299���VP4p\RVP444pVP4UUu.uFwr4V\V4\	WB43NK	upp#uuppi)c3�<"�TFwrRV9gKVx�K	R#5i)rcNr)r�rarbs&  rr��Dcall_stats_section.<locals>.calc_call_stats_table.<locals>.<genexpr>Os���H�"4�$�!�300�a��A�A�"4�s��301)rfr�rUr�r�)rc�302call_statsrrerfs&    r�calc_call_stats_table�1call_stats_section.<locals>.calc_call_stats_tableMsk���)�)�+�303��H�*�"2�"2�"4�H�H��)�.�.�0�304�0�305���%��,��e� 3�4�0�306�	307��308s�"A*z309Call statszInlined calls and frame statsa310        This shows what fraction of calls to Python functions are inlined (i.e.311        not having a call at the C level) and for those that are not, where the312        call comes from.  The various categories overlap.313 314        Also includes the count of frame objects created.315        r�r�rrkr�)r�s r�call_stats_sectionr�Ls;��316���'��(�%����
�	317�
��rc��V^8�dQhRR/#rr)rs"rrris����g�rc	�`�RRlp\RR\RV\P4.RR7#)c� �V^8�dQhRRRR/#rr)rs"rr�*object_stats_section.<locals>.__annotate__js��318�319�u�320��321rc��VP4pVP4UUUu.uFwpwr4V\V4\W443NK!	uppp#uupppirk)rurUr�r�)rc�object_statsr322rfr�s&    r�calc_object_stats_table�5object_stats_section.<locals>.calc_object_stats_tablejsW���-�-�/��(4�'9�'9�';�323�';�#��|���E�%�L�%��"3�4�';�324�	325��326��%AzObject statsz+Allocations, frees and dict materializatonsaU327        Below, "allocations" means "allocations that are not from a freelist".328        Total allocations = "Allocations from freelist" + "Allocations".329 330        "Inline values" is the number of values arrays inlined into objects.331 332        The cache hit/miss numbers are for the MRO cache, split into dunder and333        other names.334        rr�r�)r�s r�object_stats_sectionr�is;��335���5��(�'����
�	336�
��rc��V^8�dQhRR/#rr)rs"rrr�s����'�rc�B�RRlp\RR\RV4.RR7#)c� �V^8�dQhRRRR/#rr)rs"rr�&gc_stats_section.<locals>.__annotate__�s��
337�
338�U�
339�t�
340rc
�*�VP4p\V4UUu.uFfwr#\V4\VR,4\VR,4\VR,4\VR,4\VR,43NKh	upp#uuppi)r+zobjects collectedz
object visitszobjects reachable from rootsz objects not reachable from roots)r~r.r�)rcr{�i�gens&   r�
calc_gc_stats�'gc_stats_section.<locals>.calc_gc_stats�s����%�%�'��&�h�/�341342�0����a���c�-�(�)��c�-�.�/��c�/�*�+��c�8�9�:��c�<�=�>�

�0�343344�345	346��347348s�A,BzGC statsz GC collections and effectivenesszD349        Collected/visits gives some measure of efficiency.350        r)zGeneration:zCollections:zObjects collected:zObject visits:zReachable from roots:zNot reachable from roots:r+)r�s r�gc_stats_sectionr��s7��
351���*��G��
�	352�
�
�
rc��V^8�dQhRR/#rr)rs"rrr�s��j�j�g�jrc�aaaaaa�RRloRRloRRloRRRlloRR	loR353RloRRVVVVVV3R
lllp\RRV4#)c� �V^8�dQhRRRR/#rr)rs"rr�*optimization_section.<locals>.__annotate__�s��354355�356357�u�358359��360361rc
��VP4pVP4UUUu.uF$wpwr4V\V4\W4VR8gR73NK&	uppp#uupppi)r��r�)r�rUr�r�)rc�optimization_statsr362rfr�s&    r�calc_optimization_table�5optimization_section.<locals>.calc_optimization_table�si��"�9�9�;��(:�'?�'?�'A�
363�(B�#��|��	��e���e�U�o�-E�F�
�364(B�
365�	366��367��*Ac� �V^8�dQhRRRR/#rr)rs"rrr��s��368�369�E�370�d�371rc��VP4pVP4UUUu.uFwpwr4V\V4\W443NK!	uppp#uupppirk)r�rUr�r�)rc�optimizer_statsr372rfr�s&    r�calc_optimizer_table�2optimization_section.<locals>.calc_optimizer_table�sW���3�3�5��(7�'<�'<�'>�373�'>�#��|���E�%�L�%��"3�4�'>�374�	375��376r�c� �V^8�dQhRRRR/#rr)rs"rrr��s��377378�379380�U�381382�t�383384rc
��VP4pVP4UUUu.uF$wpwr4V\V4\W4VR8gR73NK&	uppp#uupppi)r�r�)r�rUr�r�)rc�jit_memory_statsr385rfr�s&    r�calc_jit_memory_table�3optimization_section.<locals>.calc_jit_memory_table�sj�� �5�5�7��(8�'=�'=�'?�
386�(@�#��|��	��e���e�U�6I�-I�J�
�387(@�
388�	389��390r�c�$�V^8�dQhRRRRRR/#)rrerr�z391str | Nonerrr)rs"rrr��s!��"�"�#�"�J�"�-�"rc�aa�RVV3RllpV#)c� �V^8�dQhRRRR/#rr)rs"rr�Hoptimization_section.<locals>.calc_histogram_table.<locals>.__annotate__�s��	%�	%��	%�$�	%rc	�<�VPS3924pS	'dVPS	4pM^pVF
wr4W$,
pK	.pVF/wrdVPRVR
2\V4\	WB434K1	^p\V4^,393pWx8:d@WW,^,^8XdV^,
pK%WX,^,^8XdV^,pKDWWV^,#)r�z<= r�)r�r�r3r�r�r0)rc�	histogram�denominatorrrbr�rar6�endr�res&        ��rr�@optimization_section.<locals>.calc_histogram_table.<locals>.calc�s�����+�+�C�0�I��#�i�i��n����%�D�A��$�K�&��D�!�������a��V���a���a�-���"��E��d�)�a�-�C��,��;�q�>�Q�&��Q�J�E��Y�q�\�Q�&��1�H�C���c�!�e�$�$rr)rer�rsff r�calc_histogram_table�2optimization_section.<locals>.calc_histogram_table�s���	%�	%�B�rc� �V^8�dQhRRRR/#rr)rs"rrr��s��	394�	395�e�	396��	397rc398���VPR4p\VP4P4UUu.uFwr#V\	V43NK	upp\^4RR7#uuppi)�unsupported_opcodeTr��r_rrMrUr�r)rc�unsupported_opcodesrCr�s&   r�calc_unsupported_opcodes_table�<optimization_section.<locals>.calc_unsupported_opcodes_table�sl��#�4�4�5I�J���&9�%J�%J�%L�%R�%R�%T�
�%T�M�F���u��&�%T�
��1�
��
399�	400��
��A$401c� �V^8�dQhRRRR/#rr)rs"rrr��s��	402�	403�5�	404�T�	405rc406���VPR4p\VP4P4UUu.uFwr#V\	V43NK	upp\^4RR7#uuppi)�error_in_opcodeTr�r�)rc�error_in_opcodesrCr�s&   r�calc_error_in_opcodes_table�9optimization_section.<locals>.calc_error_in_opcodes_table�sl�� �1�1�2C�D���&6�%G�%G�%I�%O�%O�%Q�
�%Q�M�F���u��&�%Q�
��1�
��
407�	408��
r�c� �V^8�dQhRRRR/#rr)rs"rrr�s��I409�I410�U�I411��I412rc3�8<"�VP4'dVeVP4'gR#\RS\P4x�\RS\P4x�\	RR\RS\P4.4x�\	RR\RS!R4\P4134.4x�RF7wr#\	VR2R\RS!W#4\P4144.4x�K9	\	RR\R\
R4\P4.4x�\RR	R4157x�\	RR\RS	\P4.4x�\	RR
\RS\P4.4x�R#5i)Nr�zJIT memory statsz JIT trace total memory histogramzTrace total memory sizez416 histogramzUop execution statsr��uopzNon-JIT uop)r&r�zUnsupported opcodesz!Optimizer errored out with opcodez3Optimization stopped after encountering this opcoder�)r�z
Size (bytes):rk)zSize (bytes)r�rk))zTrace lengthr�)zOptimized trace lengthr�)zTrace run lengthr�)�Rangerrkr)�Opcoder)	r�r�r�r�r�r�rr�r,)417r�r�rr�r�r�r�r�r�r�s418&&  ������r�iter_optimization_tables�6optimization_section.<locals>.iter_optimization_tabless������0�0�2�2��"�:�+L�+L�+N�+N���,�.E�x���W�W��,�.B�H�O�O�T�T�����3�)��O�O��
�419420�421	422��.�.��7�(�)B�C��+�+��
�423424�425	426�427�I�D�428��&�429�#���5�,�T�7� �/�/���430�431
�432� �!���M�.�v�6��.�.��
�433434�435	436�!��]�C�C��!���(�2��O�O��
�437438�439	440��/�A�
�'�)D�h�o�o�
V�W�441�	442�s�0F�E&FzOptimization (Tier 2) statsz%statistics about the Tier 2 optimizerrkrB)r�r�r�r�r�r�r�s @@@@@@r�optimization_sectionr��sG���443444�445�446447�"�H	448�	449�I450�I451�V�%�/� ��rc��V^8�dQhRR/#rr)rs"rrrTs����G�rc	�\�RRlp\RR\RV\P4.4#)c� �V^8�dQhRRRR/#)rrcrrr�r)rs"rr�(rare_event_section.<locals>.__annotate__Us��
Q�
Q�U�
Q�u�
Qrc��RRRRRRRRRR	R452RRR
/pVP4UUu.uF"wr#\W!V,4\V43NK$	upp#uuppi)z	set classz0Setting an object's class, `obj.__class__ = ...`z	set basesz3Setting the bases of a class, `cls.__bases__ = ...`zset eval frame funczPSetting the PEP 523 frame eval function `_PyInterpreterState_SetFrameEvalFunc()`zbuiltin dictz:Modifying the builtins, `__builtins__.__dict__[var] = ...`zfunc modificationz:Modifying a function, e.g. `func.__defaults__ = ...`, etc.zwatched dict modificationz A watched dict has been modifiedzwatched globals modificationz,A watched `globals()` dict has been modified)r�rpr�)rcrOr��ys&   r�calc_rare_event_table�1rare_event_section.<locals>.calc_rare_event_tableUso���K��N�!�;�
�X��!]�'�)K�*�,Z�453��9>�8M�8M�8O�P�8O����Q�Q���%��(�+�8O�P�P��Ps�(AzRare eventszCounts of rare/unlikely events)�Eventrr�)r�s r�rare_event_sectionr�Ts2��
Q���(�	�"�$9�8�?�?�	K�L��rc��V^8�dQhRR/#rr)rs"rrrks����G�rc	�\�RRlp\RR\RV\P4.4#)c� �V^8�dQhRRRR/#rr)rs"rr�(meta_stats_section.<locals>.__annotate__ls��J�J��J�4�Jrc�<�R\VPR443.#)zNumber of data filesrQ)r�r�)rcs&rr��%meta_stats_section.<locals>.calc_rowsls��'��u�y�y��/F�)G�H�I�Irz454Meta statszMeta statistics)r�rr�)r�s r�meta_stats_sectionr�ks0��J����	�~�y�(�/�/�	:�;��rrCc�0�V^8�dQhRRRRRRRRR	R455RR/#)
r�outr456�objzSection | Table | listr�rr�r��levelr2r�Noner)rs"rrr�sT��P@�P@�	�P@�	�P@��P@��	P@�457�P@�458�
P@rc459��RpT;\Rc;Ee$wVP'd^\RV,VPVR7\VR7\RVR7\RVPRVR7\VR7VP'd\VPVR7VeVP460RJd
\R	4M-VP
W#4Fp\WW#V^,R4617K	\VR7VP'd\RVR7\VR7R#R#;\Rc;Ee�wVPW#4wrx\V4^8XdR#.p	VF>p462V463PR4'dV	PR
4K-V	PR4K@	\RVR7\RVR7\RVR7\Wy4F5wr�V464PR4'dV465RR p466\RVRV467R2VR7K7	\RVR7\RVR7\RVR7VF�p\V4\V48wd#\R\V4,R,4h\RVR7\W�4Fwr�\RVRV!V
4R2VR7K!	\RVR7K�	\RVR7\RVR7\VR7R#\ Rc;eJwVFp\WW#VR4687K	\RVR7\R\"P$!4VR7R#R#)!c��\VR4'dVP4#\V\4'dV#VfR#\	RVR24h)r{r�zCan't convert z to markdown)�hasattrr{r�r�	TypeError)r�s&r�to_markdown�$output_markdown.<locals>.to_markdown�sI���1�j�!�!��:�:�<��
��3�
�
��H�
�Y���n�Q�C�|�<�=�=rrN�#rMz	<details>z	<summary>z469</summary>Fz$Not included in comparative output.470)r�z471</details>rL�right�leftz<table>z<thead>z<tr>z<th align="z">z</th>z</tr>z</thead>z<tbody>z!Wrong number of elements in row '�'z<td align="z</td>z</tbody>z</table>z---zStats gathered on:r*)r�r�rZr�rrr�r�output_markdownr�r�r0r%r3�ziprYrr-r�today)r�r�r�r�r�r��part�headerr��472alignments�item�alignr��cols&&&&&         rrr�s���>��
�W�Y�Y��y�y�y��c�E�k�3�9�9�3�7��3���k��,��k�3�;�;��3�G��3���w�w�w��c�g�g�C�(��%�#�/�/�U�*B��=�>��M�M�*�A�D�#�C�z�U�UV�Y�W�B��s�O��y�y�y��l��-��3���!�(�U�W�W��=�=��@�L�F��4�y�A�~���J����=�=��%�%��%�%�g�.��%�%�f�-�	�
�)�#�&��)�#�&��&�s�#�"�6�6����=�=��%�%����9�D���E�7�"�T�F�%�8�s�C� 7�
�'��$��*�3�'��)�#�&����s�8�s�6�{�*�$�;�c�#�h�F��L����f�3�'�"%�c�"6�J�C��K��w�b��S�1A�0B�%�H�s�S�#7��g�C�(��
�*�3�'��*�3�'��s�O�G�J�V�����:��O��
�%�c�"��&��473�474��3�?�rc��V^8�dQhRR/#)r�inputsz475list[Path]r)rs"rrr�s��H�H��Hrc�>�\V4;^8Xdw\\V^,44pVe+\VRRR7;_uu_4p\	W#4RRR4\V4p\
\P\V4R#^8Xd}Ve\R4h\\V^,44p\\V^,44p\V4p\V4p\
\P\Wx4R#R# +'giL�;i)r�N�wzutf-8)�encodingz5Can not output to JSON when there are multiple inputs)r0rgrr)rmrrr[�stdout�LAYOUTrY)	r476rir`�frc�	base_data�	head_datar�r�s	&&       r�output_statsr�s���477
�f�+�
� ��f�Q�i��1�D��&��+�s�W�=�=��!�$�*�>��$�K�E��C�J�J���6�
��&� �K���&�d�6�!�9�o�6�I�%�d�6�!�9�o�6�I��y�)�J��y�)�J��C�J�J��478�G��	>�=�s�D�D	c	�V�\P!RR7pVPRR\\.R\R2R7VPRRR	R4797VP4p\
VP4^8�d\R4h\VPVPR7R
#)zSummarize pystats results)�descriptionr480�*aU481        Input source(s).482        For each entry, if a .json file, the output provided by --json-output from a previous run;483        if a directory, a directory containing raw pystats .txt files.484        If one source is provided, its stats are printed.485        If two sources are provided, comparative stats are printed.486        Default is z487.488        )�nargs�typer��helpz
--json-output�?z3Output complete raw results to the given JSON file.)rrz0-2 arguments may be provided.)riN)�argparse�ArgumentParser�add_argumentr�DEFAULT_DIR�489parse_argsr0r490rYrri)�parser�argss  r�mainr"�s���
�
$�
$�1L�
M�F�491�����
��
�� �=�!	�
��
������
B�������D�492�4�;�;��!���9�:�:�����$�*:�*:�;r�__main__)zspecialization.hitr�r�rk)Nr)L�__conditional_annotations__rO�493__future__rrr+�collections.abcr�dataclassesr�datetimer�enumrPr#rS�operatorr�os�pathlibrr�r[rw�typingrr	r494rr]rrr�r-r�r
rrrr�__file__�parentsr*r�r!rGrgrmrpr2r�r�r�r�r�Enumr�r�r�rrr,rCrrr�r�r�r�r�r�r�rrrr"r})r$s@r�<module>r1s2����#���$�!�������	��	�495��3�3��#�s�(�^���#��u�+��i���3��8�_���$�#�W�I�t�O�4�
�y�4��7�7�d�?�(�K�"�K��(�^�
#�
#�A�
&�496�	G��*��6$E�N!��$��497�498��499�""�C�"�500�$��2�2��2�40��0�u�u�pv501�v502�r�t�y�y��P�P�f'�'�B�:�&$�N.�bf�Ro�d�:�<�@j�Z�.����x� �����(�*�������������503��P@�f25�t��H�*<�@�z���F�r
codekingpro/portable-devtools · Team Ai