import os
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
import collections
import tk
build_bits = [32, 64]
build_types = {'min': 'MinSizeRel',
'rel': 'Release',
'deb': 'RelWithDebInfo',
'dic': 'Release-nodict'
}
tk._prefix = '/Users/dsmirnov/work/pub-data/star-32-vs-64-build'
builds_k = list(itertools.product(build_bits, build_types.keys()))
builds_v = list(itertools.product(build_bits, build_types.values()))
Build = collections.namedtuple('Build', ['id', 'bits', 'type', 'name'])
builds = [Build(f'{kk}{kb}', kb, kk, f'{vb}-{vt}') for (kb, kk), (vb, vt) in zip(builds_k, builds_v)]
builds
[Build(id='min32', bits=32, type='min', name='32-MinSizeRel'), Build(id='rel32', bits=32, type='rel', name='32-Release'), Build(id='deb32', bits=32, type='deb', name='32-RelWithDebInfo'), Build(id='dic32', bits=32, type='dic', name='32-Release-nodict'), Build(id='min64', bits=64, type='min', name='64-MinSizeRel'), Build(id='rel64', bits=64, type='rel', name='64-Release'), Build(id='deb64', bits=64, type='deb', name='64-RelWithDebInfo'), Build(id='dic64', bits=64, type='dic', name='64-Release-nodict')]
def id_to_name(ids):
if isinstance(ids, str):
for b in builds:
if b.id==ids: return b.name
return 'NotFound'
else:
return [b.name for b in builds if b.id in ids]
#id_to_name('min32')
#id_to_name(['rel32', 'min64', 'rel64'])
libpaths = {b.id: tk.get_libpath(b) for b in builds}
logfiles = {b.id: tk.get_log(b) for b in builds}
libfiles = {}
for b in builds:
for _, _, libfiles[b.id] in os.walk(libpaths[b.id]): break
#libfiles['rel32'] == libfiles['min32'], libfiles['rel64'] == libfiles['min64']
#libfiles['rel32'], libfiles['min32']
len(libfiles['rel32'])
231
libinfo = []
for libfile in libfiles['rel32']:
libsizes = [os.path.getsize(libpath+libfile) for libpath in libpaths.values()]
libinfo.append( (libfile, *libsizes) )
df_libs = pd.DataFrame(libinfo, columns=['name']+[b.id for b in builds])
df_libs
name | min32 | rel32 | deb32 | dic32 | min64 | rel64 | deb64 | dic64 | |
---|---|---|---|---|---|---|---|---|---|
0 | libctf_Tables.so | 351444 | 397544 | 1555560 | 397688 | 424592 | 437176 | 1802312 | 437144 |
1 | libemc_Tables.so | 1181868 | 1338220 | 5351548 | 1338732 | 1421928 | 1473192 | 6224440 | 1473064 |
2 | libftpc_Tables.so | 173336 | 192376 | 722980 | 192440 | 210912 | 217328 | 840216 | 217312 |
3 | libgcalor.a | 619856 | 672768 | 1884636 | 672768 | 1055080 | 1121472 | 3230424 | 1121144 |
4 | libgeant321.a | 5132008 | 5650948 | 13155212 | 5650956 | 8551320 | 9177792 | 22073952 | 9174960 |
5 | libgen_Tables.so | 209708 | 232616 | 887536 | 232696 | 252760 | 258872 | 1029152 | 258856 |
6 | libgeometry.so | 13424 | 6477688 | 9965232 | 6498168 | 15016 | 19112 | 10593176 | 6169872 |
7 | libgeometry_Tables.so | 145808 | 161172 | 578220 | 161220 | 173816 | 180744 | 667768 | 180728 |
8 | libglobal_Tables.so | 607560 | 692084 | 2727148 | 692340 | 735424 | 761288 | 3166024 | 761224 |
9 | libRTS.so | 5378524 | 5535036 | 8014008 | 5535036 | 5439392 | 5550536 | 8667568 | 5534152 |
10 | libsim_Tables.so | 1277872 | 1458164 | 5852092 | 1458724 | 1542552 | 1601128 | 6802400 | 1600984 |
11 | libSt_base.so | 694236 | 1163128 | 2708536 | 1163320 | 865608 | 1214968 | 3220224 | 1214920 |
12 | libSt_baseTest.so | 44576 | 57244 | 287240 | 57252 | 51584 | 60216 | 323104 | 60216 |
13 | libSt_ctf.so | 108032 | 128288 | 605084 | 128312 | 130536 | 138360 | 669048 | 138352 |
14 | libSt_ctf_Maker.so | 72328 | 76100 | 262380 | 76108 | 89680 | 89272 | 296720 | 89272 |
15 | libSt_db_Maker.so | 182352 | 219496 | 736708 | 219528 | 215704 | 244712 | 888848 | 244704 |
16 | libSt_emc_Maker.so | 118464 | 134288 | 484632 | 134304 | 141648 | 149040 | 575440 | 149032 |
17 | libSt_g2t.so | 943084 | 1094112 | 5528100 | 1098496 | 1103064 | 1158128 | 6044872 | 1158056 |
18 | libSt_geant_Maker.so | 350068 | 406948 | 1574496 | 406964 | 405720 | 444816 | 2009096 | 444808 |
19 | libSt_pp2pp_Maker.so | 150920 | 166892 | 696696 | 166916 | 174584 | 186584 | 793400 | 186576 |
20 | libSt_QA_Maker.so | 491536 | 581108 | 2047488 | 581148 | 567256 | 603760 | 2348264 | 603744 |
21 | libSt_sdm_Maker.so | 81288 | 89500 | 298112 | 89508 | 98816 | 102928 | 342312 | 102920 |
22 | libSt_srs_Maker.so | 78420 | 82704 | 350576 | 82712 | 96136 | 96344 | 388408 | 96336 |
23 | libSt_tcl_Maker.so | 100820 | 104824 | 418072 | 104832 | 123704 | 123560 | 472640 | 123552 |
24 | libSt_TLA_Maker.so | 66912 | 67064 | 248352 | 67072 | 79856 | 80032 | 278456 | 80032 |
25 | libSt_trg_Maker.so | 107412 | 124056 | 419208 | 124064 | 125688 | 138264 | 477464 | 138264 |
26 | libStAnalysisMaker.so | 129388 | 141196 | 560576 | 141204 | 148608 | 156240 | 659328 | 156232 |
27 | libStAnalysisUtilities.so | 244860 | 282052 | 820552 | 282076 | 295448 | 320176 | 1028200 | 320176 |
28 | libStar2Root.so | 13312 | 13312 | 66536 | 13312 | 14888 | 14888 | 69408 | 14888 |
29 | libStarAgmlChecker.so | 154720 | 173144 | 693024 | 173176 | 178328 | 188208 | 822904 | 188200 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
201 | libStTagsMaker.so | 141060 | 147932 | 583564 | 147956 | 165880 | 168360 | 664608 | 168352 |
202 | libStTofCalibMaker.so | 153040 | 181704 | 696492 | 181712 | 176448 | 192824 | 789344 | 192824 |
203 | libStTofHitMaker.so | 102024 | 105532 | 466340 | 105548 | 120432 | 123888 | 519608 | 123888 |
204 | libStTofMaker.so | 134116 | 146244 | 642760 | 146268 | 162496 | 166352 | 715512 | 166344 |
205 | libStTofpMatchMaker.so | 155544 | 177884 | 914412 | 177892 | 179288 | 193192 | 1094928 | 193192 |
206 | libStTofrMatchMaker.so | 269040 | 319436 | 1513228 | 319468 | 303848 | 341920 | 1865440 | 341912 |
207 | libStTofSimMaker.so | 108852 | 120192 | 587632 | 120200 | 127776 | 138904 | 667360 | 138904 |
208 | libStTofUtil.so | 299588 | 346048 | 1875420 | 346096 | 345096 | 374728 | 2180152 | 374720 |
209 | libStTpcDb.so | 141956 | 158028 | 616344 | 158044 | 166024 | 177872 | 727576 | 177864 |
210 | libStTpcHitMaker.so | 340120 | 386840 | 1549408 | 386912 | 420472 | 446472 | 1858488 | 446456 |
211 | libStTpcHitMoverMaker.so | 100760 | 105048 | 409740 | 105056 | 119496 | 123784 | 462712 | 123784 |
212 | libStTpcRSMaker.so | 271656 | 319308 | 1231932 | 319332 | 316368 | 347328 | 1482720 | 347328 |
213 | libStTreeMaker.so | 128444 | 139732 | 424928 | 139756 | 156488 | 159344 | 501600 | 159336 |
214 | libStTrgDatFileReader.so | 25296 | 30200 | 143052 | 30200 | 31736 | 32664 | 152856 | 32664 |
215 | libStTrgMaker.so | 87984 | 95916 | 368640 | 95924 | 105536 | 109864 | 412840 | 109864 |
216 | libStTriggerDataMaker.so | 78044 | 82240 | 297488 | 82248 | 91080 | 95296 | 334384 | 95288 |
217 | libStTriggerUtilities.so | 1672952 | 1901512 | 8341472 | 1901696 | 1826440 | 1975736 | 9468960 | 1975696 |
218 | libStTrsMaker.so | 384912 | 447652 | 3643320 | 447684 | 445680 | 496184 | 4251792 | 496176 |
219 | libStUtilities.so | 214596 | 251524 | 1074196 | 251548 | 258656 | 287240 | 1303536 | 287240 |
220 | libStv.so | 484952 | 548216 | 2795468 | 548320 | 592296 | 630504 | 3245832 | 630472 |
221 | libStvMaker.so | 318768 | 354304 | 1635484 | 354376 | 387656 | 402272 | 1893984 | 402256 |
222 | libStVpdCalibMaker.so | 125072 | 142512 | 590824 | 142528 | 148304 | 157360 | 663696 | 157360 |
223 | libStVpdSimMaker.so | 145832 | 157544 | 707736 | 157552 | 178088 | 181552 | 796352 | 181544 |
224 | libStvSeed.so | 139504 | 153868 | 1024996 | 153884 | 162760 | 173048 | 1127328 | 173048 |
225 | libStvUtil.so | 409008 | 488596 | 1906252 | 488692 | 485712 | 536096 | 2288400 | 536072 |
226 | libStXTrakMaker.so | 158616 | 174500 | 820784 | 174524 | 192200 | 199776 | 931464 | 199768 |
227 | libStZdcVertexMaker.so | 73448 | 81788 | 333220 | 81796 | 90896 | 95136 | 366712 | 95136 |
228 | libsvt_Tables.so | 496204 | 561232 | 2212228 | 561440 | 599448 | 622432 | 2573336 | 622384 |
229 | libTPCCATracker.so | 778860 | 825368 | 5871092 | 825368 | 879504 | 924736 | 6873184 | 924736 |
230 | libxgeometry.so | 8256496 | 10413236 | 16480428 | 10446004 | 9064872 | 9669152 | 17030328 | 9669152 |
231 rows × 9 columns
bins = np.logspace(4, 9, 50)
hist_kwargs = dict(bins=bins, histtype='step', lw=1)
fig, axs = plt.subplots(1, 2, figsize=(8,4))
ax = axs[0]
for b in builds:
data = df_libs[b.id]
label = f'{b.name}: {data.sum()/1024/1024:.0f} MB'
ax.hist(data, label=label, **hist_kwargs, cumulative=False)
ax.legend(prop={'size': 8})
ax = axs[1]
for b in builds:
data = df_libs[b.id]
label = f'{b.name}: {data.sum()/1024/1024:.0f} MB'
ax.hist(data, label=label, **hist_kwargs, cumulative=True)
ax.legend(loc='lower right', prop={'size': 8})
for ax in np.ravel(axs):
ax.semilogx(), ax.grid()
ax.set_xlabel('File Size in Bytes')
plt.tight_layout()
plt.savefig('graphics/memory_lib_file_sizes.svg')
df_libs_sorted = df_libs.sort_values('min32', ascending=False, inplace=False)
#df_libs_sorted
select = df_libs_sorted.index[:20]
#select
datax = df_libs_sorted.loc[select]
#datax
value_vars = [b.id for b in builds if b.id.startswith(('rel', 'deb'))]
value_vars
['rel32', 'deb32', 'rel64', 'deb64']
datax2 = datax.melt(id_vars='name', value_vars=value_vars)
#datax2
fig = plt.figure(figsize=(7,5))
ax = sns.barplot(y='name', x='value', hue='variable', data=datax2)
ax.legend(ax.legend().get_patches(), id_to_name(value_vars))
ax.set(xlabel='File Size in Bytes', ylabel='Library Name')
ax.semilogx();
ax.grid()
plt.tight_layout()
plt.savefig('graphics/memory_lib_file_sizes_top20.svg')
value_vars = [b.id for b in builds if b.id.startswith(('rel', 'dic'))]
value_vars
['rel32', 'dic32', 'rel64', 'dic64']
datax2 = datax.melt(id_vars='name', value_vars=value_vars)
#datax2
fig = plt.figure(figsize=(7,5))
ax = sns.barplot(y='name', x='value', hue='variable', data=datax2)
ax.legend(ax.legend().get_patches(), id_to_name(value_vars))
ax.set(xlabel='File Size in Bytes', ylabel='Library Name')
ax.semilogx();
ax.grid()
plt.tight_layout()
plt.savefig('graphics/memory_lib_file_sizes_top20_nodict.svg')
memfiles = {b.id: tk.get_proc(b) for b in builds}
dfs = {}
for bid, memfile in memfiles.items():
if not os.path.isfile(memfile): continue
dfs[bid] = pd.read_csv(memfile, skipinitialspace=True)
df = pd.concat(dfs.values(), keys=dfs.keys(), names=['id'])
df.reset_index(level=0, inplace=True)
df
id | callerId | RssAnon | RssFile | RssShmem | VmHWM | VmLib | VmPeak | VmRSS | VmSize | VmSwap | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | min32 | Construct:bfc | 10.3516 | 17.7461 | 0 | 28.0977 | 60.6641 | 200.941 | 28.0977 | 200.938 | 0 |
1 | min32 | Load:libStarAgmlUtil | 13.1719 | 18.0273 | 0 | 31.1992 | 60.6953 | 203.957 | 31.1992 | 203.953 | 0 |
2 | min32 | Load:libStarAgmlLib | 13.2695 | 18.3672 | 0 | 31.6367 | 61.3320 | 204.621 | 31.6367 | 204.617 | 0 |
3 | min32 | Load:libGeometry | 13.2891 | 18.3750 | 0 | 31.6641 | 61.3398 | 204.637 | 31.6641 | 204.633 | 0 |
4 | min32 | Load:libStarGeometry | 14.8984 | 24.6953 | 0 | 39.5938 | 76.0391 | 220.977 | 39.5938 | 220.973 | 0 |
5 | min32 | Load:libStDb_Tables | 16.4766 | 32.0234 | 0 | 48.5000 | 85.4883 | 231.887 | 48.5000 | 231.883 | 0 |
6 | min32 | Load:libemc_Tables | 16.5977 | 32.6484 | 0 | 49.2461 | 86.2617 | 232.840 | 49.2461 | 232.836 | 0 |
7 | min32 | Load:libgeometry_Tables | 16.6172 | 32.7266 | 0 | 49.3438 | 86.3555 | 232.945 | 49.3438 | 232.941 | 0 |
8 | min32 | Load:libglobal_Tables | 16.6797 | 33.0352 | 0 | 49.7148 | 86.7578 | 233.375 | 49.7148 | 233.371 | 0 |
9 | min32 | Load:libsim_Tables | 16.8477 | 33.6914 | 0 | 50.5391 | 87.6016 | 234.445 | 50.5391 | 234.441 | 0 |
10 | min32 | Load:libVMC | 16.9023 | 33.7852 | 0 | 50.6875 | 87.8555 | 234.711 | 50.6875 | 234.707 | 0 |
11 | min32 | Load:libStarMagField | 16.9180 | 33.8281 | 0 | 50.7461 | 87.9297 | 234.793 | 50.7461 | 234.789 | 0 |
12 | min32 | Load:libxgeometry | 16.9492 | 33.9023 | 0 | 50.8516 | 98.8203 | 247.484 | 50.8516 | 247.480 | 0 |
13 | min32 | Load:libRTS | 17.0312 | 34.0352 | 0 | 51.0664 | 99.6484 | 308.453 | 51.0664 | 308.449 | 0 |
14 | min32 | Load:libStDaqLib | 18.1289 | 34.1289 | 0 | 52.2578 | 99.9805 | 309.980 | 52.2578 | 309.977 | 0 |
15 | min32 | Load:libStDAQMaker | 18.1367 | 34.2031 | 0 | 52.3398 | 100.0980 | 310.109 | 52.3398 | 310.105 | 0 |
16 | min32 | Load:libStarClassLibrary | 18.2578 | 34.5469 | 0 | 52.8047 | 100.6990 | 310.895 | 52.8047 | 310.891 | 0 |
17 | min32 | Load:libStTableUtilities | 18.2852 | 34.5938 | 0 | 52.8789 | 100.7580 | 310.965 | 52.8789 | 310.961 | 0 |
18 | min32 | Load:libStTofUtil | 18.3008 | 34.6992 | 0 | 53.0000 | 100.9690 | 311.188 | 53.0000 | 311.184 | 0 |
19 | min32 | Load:libStBTofUtil | 18.3203 | 34.8125 | 0 | 53.1328 | 101.1760 | 311.406 | 53.1328 | 311.402 | 0 |
20 | min32 | Load:libStMtdUtil | 18.3516 | 34.8711 | 0 | 53.2227 | 101.2700 | 311.512 | 53.2227 | 311.508 | 0 |
21 | min32 | Load:libStBichsel | 18.3594 | 34.9297 | 0 | 53.2891 | 101.3750 | 311.625 | 53.2891 | 311.621 | 0 |
22 | min32 | Load:libStEvent | 19.2461 | 36.8789 | 0 | 56.1250 | 107.1250 | 318.262 | 56.1250 | 318.258 | 0 |
23 | min32 | Load:libStEmcUtil | 19.2852 | 37.0469 | 0 | 56.3320 | 107.5700 | 318.723 | 56.3320 | 318.719 | 0 |
24 | min32 | Load:libStEEmcUtil | 19.4414 | 37.2734 | 0 | 56.7148 | 108.0700 | 319.824 | 56.7148 | 319.820 | 0 |
25 | min32 | Load:libStPmdUtil | 19.4844 | 37.3594 | 0 | 56.8438 | 108.2970 | 320.207 | 56.8438 | 320.203 | 0 |
26 | min32 | Load:libStEventUtilities | 19.5391 | 37.6133 | 0 | 57.1523 | 108.8010 | 320.746 | 57.1523 | 320.742 | 0 |
27 | min32 | Load:libStStrangeMuDstMaker | 19.8750 | 38.0820 | 0 | 57.9570 | 109.3480 | 321.711 | 57.9570 | 321.711 | 0 |
28 | min32 | Load:libTree | 19.8945 | 38.0820 | 0 | 57.9766 | 109.3480 | 321.711 | 57.9766 | 321.703 | 0 |
29 | min32 | Load:libStMuDSTMaker | 20.0977 | 38.8242 | 0 | 58.9219 | 111.0080 | 323.562 | 58.9219 | 323.559 | 0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
350 | dic64 | EndMaker:MtdChain | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
351 | dic64 | EndMaker:tpc_hits | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
352 | dic64 | EndMaker:tpc_hit_mover | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
353 | dic64 | EndMaker:tpcChain | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
354 | dic64 | EndMaker:epdHit | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
355 | dic64 | EndMaker:StZdcVertexMaker | 610.0980 | 70.9141 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0120 | 1429.510 | 0 |
356 | dic64 | EndMaker:emcRaw | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
357 | dic64 | EndMaker:preecl | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
358 | dic64 | EndMaker:epc | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
359 | dic64 | EndMaker:tof_raw | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
360 | dic64 | EndMaker:vpdCalib | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
361 | dic64 | EndMaker:BTofChain | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
362 | dic64 | EndMaker:l3RawReader | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
363 | dic64 | EndMaker:GenericVertex | 610.0980 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0200 | 1429.510 | 0 |
364 | dic64 | EndMaker:Sti | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
365 | dic64 | EndMaker:dEdxY2 | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
366 | dic64 | EndMaker:btofMatch | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
367 | dic64 | EndMaker:btofCalib | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
368 | dic64 | EndMaker:MtdMatch | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
369 | dic64 | EndMaker:StEventCompendiumMaker | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
370 | dic64 | EndMaker:HeavyTag | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
371 | dic64 | EndMaker:HighPtTags | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
372 | dic64 | EndMaker:tags | 610.1210 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0430 | 1429.510 | 0 |
373 | dic64 | EndMaker:strangeMuDst | 610.1250 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.0470 | 1429.510 | 0 |
374 | dic64 | EndMaker:MuDst | 610.2460 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1680 | 1429.510 | 0 |
375 | dic64 | EndMaker:PicoDst | 610.2540 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1760 | 1429.510 | 0 |
376 | dic64 | EndMaker:EventQA | 610.2540 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1760 | 1429.510 | 0 |
377 | dic64 | EndMaker:outputStream | 610.2540 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1760 | 1429.510 | 0 |
378 | dic64 | EndMaker:analysis | 610.2540 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1760 | 1429.510 | 0 |
379 | dic64 | EndMaker:rts_reader | 610.2540 | 70.9219 | 0 | 689.8480 | 147.4770 | 1444.250 | 681.1760 | 1429.510 | 0 |
3046 rows × 11 columns
len(dfs['rel32']), len(dfs['rel64']), len(dfs['deb32']), len(dfs['deb64'])
(381, 381, 381, 381)
def make_fig(data, figname, title='', labelsize=10):
fig = plt.figure(figsize=(7,5))
ax = sns.pointplot(x='callerId', y='VmSize', hue='id', data=data, markers='x',scale=0.8)#, palette=['C0', 'C0'])
ax = sns.pointplot(x='callerId', y='VmRSS', hue='id', data=data, markers='.', scale=0.8)#, palette=['C1', 'C1'])
ax = sns.pointplot(x='callerId', y='VmLib', hue='id', data=data, markers='+', scale=0.8)#, palette=['C2', 'C2'])
ax.tick_params(axis='x', labelrotation=90, labelsize=labelsize)
ax.grid()
ax.set_ylim(bottom=0)
ax.set(title=title, xlabel='', ylabel='Memory Usage, MB');
#[t.set_text(id_to_name(t.get_text())) for t in ax.legend().get_texts()]
ax.get_legend().remove()
plt.tight_layout()
plt.savefig('graphics/'+figname+'.svg')
select = df.callerId.str.contains('Construct:') & df.id.str.contains('rel')
data = df.loc[select].copy()
data.callerId = data.callerId.str.replace('Construct:', '')
make_fig(data, 'memory_calls_constructor_rel', 'StMaker::StMaker() Calls')
select = df.callerId.str.contains('Construct') & (df.id.str.contains('rel')|df.id.str.contains('dic'))
data = df.loc[select].copy()
data.callerId = data.callerId.str.replace('Construct:', '')
make_fig(data, 'memory_calls_constructor_rel_dic', 'StMaker::StMaker() Calls')
select = df.callerId.str.contains('Load:') & (df.id.str.contains('rel'))
#select = df.callerId.str.contains('Load:') & (df.id.str.contains('rel')|df.id.str.contains('dic'))
data = df.loc[select].copy()
data.callerId = data.callerId.str.replace('Load:', '')
make_fig(data, 'memory_calls_load', 'ROOT::Load(\"libFoo.so\") Calls', 5)
#make_fig(data, 'memory_calls_load_rel_dic', 'ROOT::Load(\"libFoo.so\") Calls', 5)
select = df.callerId.str.contains('Load:') & (df.id.str.contains('rel'))
#select = df.callerId.str.contains('Load:') & (df.id.str.contains('rel')|df.id.str.contains('dic'))
data = df.loc[select].copy()
data.callerId = data.callerId.str.replace('Load:', '')
make_fig(data, 'memory_calls_load', 'ROOT::Load(\"libFoo.so\") Calls', 5)
#make_fig(data, 'memory_calls_load_rel_dic', 'ROOT::Load(\"libFoo.so\") Calls', 5)
select = df.callerId.str.contains('Init:') & df.id.str.contains('rel')
data = df.loc[select].copy()
data.callerId = data.callerId.str.replace('Init:', '')
make_fig(data, 'memory_calls_init', 'StMaker::Init() Calls')
def call_indices(df):
load = [df.index[ (df.callerId.str.contains('Load:')) ][0]]
con = df.index[ (df.callerId.str.contains('Construct:inputStream')) ]
ini = df.index[ (df.callerId.str.contains('Init:inputStream')) ]
clr = df.index[ (df.callerId.str.contains('Clear:analysis')) ]
evt = df.index[ (df.callerId.str.contains('EndMaker:inputStream')) ]
return load, con, ini, clr, evt
idx_load, idx_con, idx_ini, idx_clr, idx_evt = call_indices(dfs['rel32'])
def plot_vertical_lines(indices, color):
for idx in indices:
plt.plot([idx, idx], plt.ylim(), f'{color}')
xticks_ = np.sort(idx_load + idx_con.tolist() + idx_ini.tolist() + idx_clr.tolist() + idx_evt.tolist())
xlabels_ = ['$\\longrightarrow$\nLoad Libs', '$\\longrightarrow$\nConstr.',
'$\\longrightarrow$\nInit()',
'$\\longrightarrow$\nClear()\n#1', '$\\longrightarrow$\nMake()',
'$\\longrightarrow$\nClear()\n#2', '$\\longrightarrow$\nMake()',
'$\\longrightarrow$\nClear()\n#3', '$\\longrightarrow$\nMake()']
fig = plt.figure( figsize=(8,4))
for b in builds:
if b.id.startswith(('deb', 'dic')): continue
data = dfs[b.id].VmSize
plt.plot(np.arange(len(data)), data, label=b.name)
plt.ylim(bottom=0, top=1500)
plot_vertical_lines(idx_load, 'C0:')
plot_vertical_lines(idx_con, 'C1:')
plot_vertical_lines(idx_ini, 'C2:')
plot_vertical_lines(idx_clr, 'C3:')
plot_vertical_lines(idx_evt, 'C4:')
plt.xticks(xticks_, xlabels_, ha='left', size=10)
plt.legend()
plt.grid()
plt.gca().set(ylabel='MB')
plt.tight_layout()
plt.savefig('graphics/memory_calls_overall.svg')
fig = plt.figure( figsize=(8,4))
for b in builds:
if b.id.startswith(('deb', 'dic')): continue
data = dfs[b.id].VmRSS
plt.plot(np.arange(len(data)), data, label=b.name)
plt.ylim(bottom=0, top=1500)
plot_vertical_lines(idx_load, 'C0:')
plot_vertical_lines(idx_con, 'C1:')
plot_vertical_lines(idx_ini, 'C2:')
plot_vertical_lines(idx_clr, 'C3:')
plot_vertical_lines(idx_evt, 'C4:')
plt.xticks(xticks_, xlabels_, ha='left', size=10)
plt.legend()
plt.grid()
plt.gca().set(ylabel='MB')
plt.tight_layout()
plt.savefig('graphics/memory_calls_overall.svg')
fig = plt.figure(figsize=(8,4))
data32 = dfs['rel32'].VmRSS.values
data64 = dfs['rel64'].VmRSS.values
delta = data64-data32
plt.plot(np.arange(len(data32)), delta, label='64 - 32')
plt.ylim(bottom=0)
plt.gca().set(ylabel='MB')
plt.legend()
plt.grid(True)
plt.xticks(xticks_, xlabels_, ha='left', size=10)
plt.twinx()
plt.plot([0,len(delta)-1], [delta[0]/np.max(delta)*100, delta[-1]/np.max(delta)*100], '.', label='64 - 32')
plt.gca().tick_params('y', colors='r')
plt.grid(color='r')
plt.ylim(bottom=0)
plt.tight_layout()
plt.savefig('graphics/memory_calls_diff.svg')
#fig = plt.figure( figsize=(8,4))
#
#for b in builds:
# data = dfs[b.id].heap
# plt.plot(np.arange(len(data)), data, label=b.name)
#
#plt.ylim(bottom=0)
#
#plt.legend()
#plt.grid()
#plt.gca().set(xlabel='MemStat Call', ylabel='Mb')
#plt.tight_layout()
#import cxxfilt
from elftools.elf.elffile import ELFFile
from elftools.construct import Container
from pandas.io.json import json_normalize
def todict(dict_with_container):
mydict = {}
for key, value in dict_with_container.items():
if isinstance(value, Container):
mydict[key] = todict(value.__dict__)
else:
mydict[key] = value
return mydict
def symbol_to_dict(sym):
try:
return dict(name=cxxfilt.demangle(sym.name), entry=todict(sym.entry), cf=True)
except:
return dict(name=sym.name, entry=todict(sym.entry), cf=False)
def make_sym_df(libfull):
with open(libfull, 'rb') as f:
try:
elffile = ELFFile(f)
symbols = [sym for sym in elffile.get_section_by_name('.symtab').iter_symbols()]
symbols_list = [symbol_to_dict(symbol) for symbol in symbols]
df = pd.DataFrame(json_normalize(symbols_list, sep='_'))
isrootgen = df.name.str.contains('_dictLN_|_dict_|ROOTDict|G__')
df = df.assign(r=isrootgen)
return df
except:
return None
def calc_stats(df):
# Calculate fraction of c++filt failed
frac_failed_cppfilt = float(np.count_nonzero(df.cf))/len(df.cf)
total_st_size = df.entry_st_size.sum()
root_st_size = df.loc[df.r].entry_st_size.sum()
frac_root_size = float(root_st_size)/total_st_size
frac_root_numb = float(np.count_nonzero(df.r))/len(df.r)
return dict(size_st=total_st_size,
#frac_cf=frac_failed_cppfilt,
frac_rs=frac_root_size,
frac_rn=frac_root_numb
)
def make_stats_dict(build, libfile):
libfull = tk.get_libpath(build) + libfile
df = make_sym_df(libfull)
if df is None: return None
stats = calc_stats(df)
size = os.path.getsize(libfull)
return dict(size=size, **stats)
libstats = []
libfiles_selected = [lf for lf in libfiles['rel32'] if '.so' in lf]
#libfiles_selected = [lf for lf in libfiles_selected if any(s in lf for s in ['RTS', 'Sti', 'StEvent', 'Db', 'db'])]
libfiles_selected = [lf for lf in libfiles_selected if any(s in lf for s in ['RTS', 'Sti', 'StEvent'])]
libfiles_selected
['libRTS.so', 'libStEvent.so', 'libStEventCompendiumMaker.so', 'libStEventMaker.so', 'libStEventUtilities.so', 'libStGenericVertexMakerNoSti.so', 'libSti.so', 'libStiCA.so', 'libStiIst.so', 'libStiMaker.so', 'libStiPxl.so', 'libStiRnD.so', 'libStiSsd.so', 'libStiSvt.so', 'libStiTpc.so', 'libStiUtilities.so']
for idx, libfile in enumerate(libfiles_selected):
print(f'{idx:3d} processing {libfile}')
for b in builds:
#if 'rel' not in b.id: continue
if 'deb' in b.id: continue
libstat = make_stats_dict(b, libfile)
if libstat is None:
print('^^^ skipping...')
break
libstats.append( dict(name=libfile, bid=b.id, **libstat) )
#import pprint
#pprint.pprint(libstats)
0 processing libRTS.so 1 processing libStEvent.so 2 processing libStEventCompendiumMaker.so 3 processing libStEventMaker.so 4 processing libStEventUtilities.so 5 processing libStGenericVertexMakerNoSti.so 6 processing libSti.so 7 processing libStiCA.so 8 processing libStiIst.so 9 processing libStiMaker.so 10 processing libStiPxl.so 11 processing libStiRnD.so 12 processing libStiSsd.so 13 processing libStiSvt.so 14 processing libStiTpc.so 15 processing libStiUtilities.so
df = pd.DataFrame(json_normalize(libstats, sep='_'))
df
name | bid | size | size_st | frac_rs | frac_rn | |
---|---|---|---|---|---|---|
0 | libRTS.so | min32 | 5378524 | 63552139 | 0.000013 | 0.014980 |
1 | libRTS.so | rel32 | 5535036 | 63670584 | 0.000016 | 0.012736 |
2 | libRTS.so | dic32 | 5535036 | 63670584 | 0.000016 | 0.012736 |
3 | libRTS.so | min64 | 5439392 | 63561281 | 0.000011 | 0.015370 |
4 | libRTS.so | rel64 | 5550536 | 63650905 | 0.000012 | 0.015385 |
5 | libRTS.so | dic64 | 5534152 | 63650905 | 0.000012 | 0.015385 |
6 | libStEvent.so | min32 | 8270624 | 3475991 | 0.719584 | 0.533661 |
7 | libStEvent.so | rel32 | 10234444 | 5290411 | 0.786988 | 0.542278 |
8 | libStEvent.so | dic32 | 10238140 | 5290411 | 0.786988 | 0.542278 |
9 | libStEvent.so | min64 | 9807096 | 4125368 | 0.777492 | 0.537043 |
10 | libStEvent.so | rel64 | 10697520 | 4864355 | 0.776331 | 0.546917 |
11 | libStEvent.so | dic64 | 10696600 | 4864355 | 0.776331 | 0.546917 |
12 | libStEventCompendiumMaker.so | min32 | 79244 | 13019 | 0.482986 | 0.176699 |
13 | libStEventCompendiumMaker.so | rel32 | 83544 | 16428 | 0.543949 | 0.175676 |
14 | libStEventCompendiumMaker.so | dic32 | 83552 | 16428 | 0.543949 | 0.175676 |
15 | libStEventCompendiumMaker.so | min64 | 96976 | 13633 | 0.527837 | 0.177388 |
16 | libStEventCompendiumMaker.so | rel64 | 101312 | 14863 | 0.539864 | 0.176357 |
17 | libStEventCompendiumMaker.so | dic64 | 101312 | 14863 | 0.539864 | 0.176357 |
18 | libStEventMaker.so | min32 | 156596 | 46260 | 0.174730 | 0.116307 |
19 | libStEventMaker.so | rel32 | 177356 | 66162 | 0.183534 | 0.115752 |
20 | libStEventMaker.so | dic32 | 177364 | 66162 | 0.183534 | 0.115752 |
21 | libStEventMaker.so | min64 | 181376 | 45500 | 0.215582 | 0.116867 |
22 | libStEventMaker.so | rel64 | 198136 | 60018 | 0.179596 | 0.116168 |
23 | libStEventMaker.so | dic64 | 198128 | 60018 | 0.179596 | 0.116168 |
24 | libStEventUtilities.so | min32 | 733724 | 264036 | 0.498125 | 0.293541 |
25 | libStEventUtilities.so | rel32 | 867328 | 389560 | 0.559814 | 0.295988 |
26 | libStEventUtilities.so | dic32 | 867528 | 389560 | 0.559814 | 0.295988 |
27 | libStEventUtilities.so | min64 | 904448 | 299576 | 0.558299 | 0.294805 |
28 | libStEventUtilities.so | rel64 | 984048 | 372210 | 0.542731 | 0.298011 |
29 | libStEventUtilities.so | dic64 | 984000 | 372210 | 0.542731 | 0.298011 |
... | ... | ... | ... | ... | ... | ... |
66 | libStiRnD.so | min32 | 141760 | 41928 | 0.326631 | 0.224764 |
67 | libStiRnD.so | rel32 | 154088 | 54904 | 0.335604 | 0.223861 |
68 | libStiRnD.so | dic32 | 115008 | 37419 | 0.027419 | 0.055649 |
69 | libStiRnD.so | min64 | 165936 | 42373 | 0.353621 | 0.225676 |
70 | libStiRnD.so | rel64 | 174160 | 50548 | 0.343476 | 0.224462 |
71 | libStiRnD.so | dic64 | 129272 | 33835 | 0.021753 | 0.055838 |
72 | libStiSsd.so | min32 | 136768 | 37119 | 0.305208 | 0.201635 |
73 | libStiSsd.so | rel32 | 154260 | 53791 | 0.289509 | 0.196809 |
74 | libStiSsd.so | dic32 | 120828 | 39170 | 0.026194 | 0.053140 |
75 | libStiSsd.so | min64 | 160888 | 37433 | 0.327919 | 0.202462 |
76 | libStiSsd.so | rel64 | 178568 | 49976 | 0.290459 | 0.197333 |
77 | libStiSsd.so | dic64 | 139512 | 36121 | 0.020376 | 0.053312 |
78 | libStiSvt.so | min32 | 110836 | 23667 | 0.387333 | 0.208000 |
79 | libStiSvt.so | rel32 | 119400 | 30695 | 0.413129 | 0.206022 |
80 | libStiSvt.so | dic32 | 87072 | 18932 | 0.054194 | 0.064453 |
81 | libStiSvt.so | min64 | 134576 | 23449 | 0.425818 | 0.208668 |
82 | libStiSvt.so | rel64 | 139056 | 28517 | 0.406845 | 0.206677 |
83 | libStiSvt.so | dic64 | 105320 | 17555 | 0.041925 | 0.064706 |
84 | libStiTpc.so | min32 | 128044 | 29623 | 0.343652 | 0.187328 |
85 | libStiTpc.so | rel32 | 132168 | 36099 | 0.400759 | 0.187070 |
86 | libStiTpc.so | dic32 | 99716 | 22595 | 0.045408 | 0.054366 |
87 | libStiTpc.so | min64 | 152112 | 29220 | 0.388227 | 0.188105 |
88 | libStiTpc.so | rel64 | 156240 | 33500 | 0.388866 | 0.187586 |
89 | libStiTpc.so | dic64 | 122384 | 21146 | 0.034806 | 0.054545 |
90 | libStiUtilities.so | min32 | 161140 | 53340 | 0.514717 | 0.283525 |
91 | libStiUtilities.so | rel32 | 189576 | 79264 | 0.570410 | 0.284251 |
92 | libStiUtilities.so | dic32 | 88652 | 26377 | 0.038898 | 0.068750 |
93 | libStiUtilities.so | min64 | 192800 | 59161 | 0.610757 | 0.285347 |
94 | libStiUtilities.so | rel64 | 208808 | 72132 | 0.565117 | 0.286452 |
95 | libStiUtilities.so | dic64 | 104936 | 25386 | 0.028992 | 0.069620 |
96 rows × 6 columns
select = df.bid.str.contains('rel') |df.bid.str.contains('dic')
data = df.loc[select]
fig = plt.figure(figsize=(8,6))
ax = sns.barplot(x='size', y='name', hue='bid', data=data)
ax.semilogx()
ax.grid()
_ = [t.set_text(id_to_name(t.get_text())) for t in ax.legend().get_texts()]
plt.savefig('graphics/memory_select_elf_size.svg')
fig = plt.figure(figsize=(8,6))
#ax = sns.barplot(x=data['size_st']/data['size'], y='name', hue='bid', data=data)
ax = sns.barplot(x='size_st', y='name', hue='bid', data=data)
ax.semilogx()
ax.grid()
_ = [t.set_text(id_to_name(t.get_text())) for t in ax.legend().get_texts()]
plt.savefig('graphics/memory_select_elf_size_st.svg')
fig = plt.figure(figsize=(8,6))
ax = sns.barplot(y='name', x='frac_rs', hue='bid', data=data)
ax.semilogx()
ax.grid()
_ = [t.set_text(id_to_name(t.get_text())) for t in ax.legend().get_texts()]
plt.savefig('graphics/memory_select_elf_frac_rs.svg')
libname = 'libSti.so'
#libname = 'libStEvent.so'
df = make_sym_df(libpaths['rel32']+libname)
df
name | cf | entry_st_name | entry_st_value | entry_st_size | entry_st_info_bind | entry_st_info_type | entry_st_other_visibility | entry_st_shndx | r | |
---|---|---|---|---|---|---|---|---|---|---|
0 | False | 0 | 0 | 0 | STB_LOCAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | False | |
1 | False | 0 | 276 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 1 | False | |
2 | False | 0 | 312 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 2 | False | |
3 | False | 0 | 13636 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 3 | False | |
4 | False | 0 | 49780 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 4 | False | |
5 | False | 0 | 131762 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 5 | False | |
6 | False | 0 | 136280 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 6 | False | |
7 | False | 0 | 136488 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 7 | False | |
8 | False | 0 | 159904 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 8 | False | |
9 | False | 0 | 166120 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 9 | False | |
10 | False | 0 | 166160 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 10 | False | |
11 | False | 0 | 178608 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 11 | False | |
12 | False | 0 | 808280 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 12 | False | |
13 | False | 0 | 808320 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 13 | False | |
14 | False | 0 | 871256 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 14 | False | |
15 | False | 0 | 888676 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 15 | False | |
16 | False | 0 | 988080 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 16 | False | |
17 | False | 0 | 1005092 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 17 | False | |
18 | False | 0 | 1005272 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 18 | False | |
19 | False | 0 | 1005276 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 19 | False | |
20 | False | 0 | 1005280 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 20 | False | |
21 | False | 0 | 1013820 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 21 | False | |
22 | False | 0 | 1014076 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 22 | False | |
23 | False | 0 | 1015808 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 23 | False | |
24 | False | 0 | 1018944 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 24 | False | |
25 | False | 0 | 1023360 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 25 | False | |
26 | False | 0 | 0 | 0 | STB_LOCAL | STT_SECTION | STV_DEFAULT | 26 | False | |
27 | EditableParameter.cxx | False | 1 | 0 | 0 | STB_LOCAL | STT_FILE | STV_DEFAULT | SHN_ABS | False |
28 | _ZStlsISt11char_traitsIcEERSt13basic_ostreamIc... | False | 23 | 178608 | 43 | STB_LOCAL | STT_FUNC | STV_DEFAULT | 11 | False |
29 | _GLOBAL__sub_I_EditableParameter.cxx | False | 86 | 179760 | 64 | STB_LOCAL | STT_FUNC | STV_DEFAULT | 11 | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
3813 | _ZN5NamedD1Ev | False | 154999 | 189168 | 105 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3814 | _ZN18StiKalmanTrackNode12getGlobalTptEPfS0_ | False | 155013 | 335632 | 325 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3815 | _ZN10StiFactoryI10StiNodeInfS0_E4freeEPS0_ | False | 155057 | 217296 | 28 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3816 | _ZN7TObject6NotifyEv | False | 155100 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | False |
3817 | _ZN20StiDetectorContainer6moveInEddd | False | 155121 | 264464 | 425 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3818 | G__Sti_dictLN_vectorlETGeoVolumeAssemblycLcLTh... | False | 155158 | 1022616 | 8 | STB_GLOBAL | STT_OBJECT | STV_DEFAULT | 24 | True |
3819 | _ZN20ConstrainedParameterC2Ev | False | 155272 | 184656 | 64 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3820 | G__defined_typename | False | 155302 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | True |
3821 | _ZTV23StiGenericDetectorGroup | False | 155322 | 1010088 | 24 | STB_WEAK | STT_OBJECT | STV_DEFAULT | 20 | False |
3822 | _ZTI6StiHit | False | 155352 | 1013744 | 8 | STB_WEAK | STT_OBJECT | STV_DEFAULT | 20 | False |
3823 | _ZN14StiKalmanTrack6refitLEv | False | 155364 | 303600 | 409 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3824 | _ZTV5Named | False | 155393 | 1005784 | 16 | STB_WEAK | STT_OBJECT | STV_DEFAULT | 20 | False |
3825 | _ZSt16__insertion_sortIN9__gnu_cxx17__normal_i... | False | 155404 | 280192 | 179 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3826 | _ZN10TIdTruUtil3AddEii | False | 155550 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | False |
3827 | _ZN6StiHitC2Ev | False | 155573 | 286224 | 32 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3828 | _ZNSt6vectorIP18StiKalmanTrackNodeSaIS1_EE19_M... | False | 155588 | 317200 | 226 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3829 | G__Sti_dictLN_StThreeVectorlEdoublegR | False | 155668 | 1022688 | 8 | STB_GLOBAL | STT_OBJECT | STV_DEFAULT | 24 | True |
3830 | _ZNK14StiKalmanTrack7getDca2EP8StiTrack | False | 155706 | 316336 | 3 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3831 | _ZN14StiTrackFinder4findEP8StiTrackid | False | 155746 | 330080 | 3 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3832 | _ZN6FilterI8StiTrackED0Ev | False | 155784 | 245776 | 43 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3833 | _ZN6StiHitD1Ev | False | 155810 | 284960 | 2 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3834 | _ZN18StiKalmanTrackNode8setStateEPKS_ | False | 155825 | 334224 | 147 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | False |
3835 | _ZN8TDataSet8AddFirstEPS_ | False | 155863 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | False |
3836 | _ZN8ROOTDict20GenerateInitInstanceEPK15StiHitC... | False | 155889 | 769440 | 5 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | True |
3837 | _ZN8ROOTDict20GenerateInitInstanceEPK18StiDete... | False | 155944 | 769392 | 5 | STB_GLOBAL | STT_FUNC | STV_DEFAULT | 11 | True |
3838 | _ZN14StiTrackFinder14getTrackFilterEv | False | 156002 | 330176 | 3 | STB_WEAK | STT_FUNC | STV_DEFAULT | 11 | False |
3839 | _ZN18G__FastAllocString6GetBufERj | False | 156040 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | True |
3840 | _ZTS10Parameters | False | 156074 | 808562 | 13 | STB_WEAK | STT_OBJECT | STV_DEFAULT | 13 | False |
3841 | _ZN8TVector37RotateZEd | False | 156091 | 0 | 0 | STB_GLOBAL | STT_NOTYPE | STV_DEFAULT | SHN_UNDEF | False |
3842 | _ZTS7FactoryI6StiHitE | False | 156114 | 813943 | 18 | STB_WEAK | STT_OBJECT | STV_DEFAULT | 13 | False |
3843 rows × 10 columns
plt.hist(df32.entry_st_size, label='32', bins=np.logspace(0, 5, 101), histtype='step')
plt.hist(df32t.entry_st_size, label='32t', bins=np.logspace(0, 5, 101), histtype='step')
plt.hist(df64.entry_st_size, label='64', bins=np.logspace(0, 5, 101), histtype='step')
plt.semilogx()
#plt.semilogy()
plt.grid()
plt.legend()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-54-d55a73ea9749> in <module> ----> 1 plt.hist(df32.entry_st_size, label='32', bins=np.logspace(0, 5, 101), histtype='step') 2 plt.hist(df32t.entry_st_size, label='32t', bins=np.logspace(0, 5, 101), histtype='step') 3 plt.hist(df64.entry_st_size, label='64', bins=np.logspace(0, 5, 101), histtype='step') 4 plt.semilogx() 5 #plt.semilogy() NameError: name 'df32' is not defined
bins = np.logspace(0, 5, 101)
plt.hist(df32.entry_st_size, label='32', bins=bins, histtype='step', cumulative=True)
plt.hist(df32t.entry_st_size, label='32t', bins=bins, histtype='step', cumulative=True)
plt.hist(df64.entry_st_size, label='64', bins=bins, histtype='step', cumulative=True)
plt.semilogx()
plt.grid()
plt.legend(loc='lower center')
def select_symbols(df):
sel_fnc = df.entry_st_info_type == 'STT_FUNC'
sel_obj = df.entry_st_info_type == 'STT_OBJECT'
sel_w = df.entry_st_info_bind == 'STB_WEAK'
sel_g = df.entry_st_info_bind == 'STB_GLOBAL'
sel_l = df.entry_st_info_bind == 'STB_LOCAL'
return sel_fnc, sel_obj, sel_w, sel_g, sel_l
#df.loc[sel_l]
def select_symbol_sizes(df):
sel_fnc, sel_obj, sel_w, sel_g, sel_l = select_symbols(df)
f = df.loc[sel_fnc].entry_st_size
o = df.loc[sel_obj].entry_st_size
fl = df.loc[sel_fnc&sel_l].entry_st_size
fg = df.loc[sel_fnc&sel_g].entry_st_size
fw = df.loc[sel_fnc&sel_w].entry_st_size
flr = df.loc[sel_fnc&sel_l&df.r].entry_st_size
fgr = df.loc[sel_fnc&sel_g&df.r].entry_st_size
fwr = df.loc[sel_fnc&sel_w&df.r].entry_st_size
ol = df.loc[sel_obj&sel_l].entry_st_size
og = df.loc[sel_obj&sel_g].entry_st_size
ow = df.loc[sel_obj&sel_w].entry_st_size
olr = df.loc[sel_obj&sel_l&df.r].entry_st_size
ogr = df.loc[sel_obj&sel_g&df.r].entry_st_size
owr = df.loc[sel_obj&sel_w&df.r].entry_st_size
return f, o, fl, fg, fw, flr, fgr, fwr, ol, og, ow, olr, ogr, owr
f32, o32, fl32, fg32, fw32, fl32r, fg32r, fw32r, ol32, og32, ow32, ol32r, og32r, ow32r = select_symbol_sizes(df32)
f32t, o32t, fl32t, fg32t, fw32t, fl32rt, fg32rt, fw32rt, ol32t, og32t, ow32t, ol32rt, og32rt, ow32rt = select_symbol_sizes(df32t)
f64, o64, fl64, fg64, fw64, fl64r, fg64r, fw64r, ol64, og64, ow64, ol64r, og64r, ow64r = select_symbol_sizes(df64)
def change_in_size(s32, s64):
change = (s64.sum() - s32.sum())/s32.sum()*100
return f'Total Size 32: {s32.sum()/1024/1024:.2f}Mb\nTotal Size 64: {s64.sum()/1024/1024:.2f}Mb\nChange in size: {change:+.1f}%'
h_kwargs = dict(bins=np.logspace(0, 4, 101), cumulative=-1, histtype='step')
#lib_labels = ['64', '32']
lib_labels = ['32t', '32']
fig, axs = plt.subplots(1, 2, figsize=(8,4), sharey='row')#, gridspec_kw=dict(wspace=0))
ax = axs[0]
#ax.hist([f64, f32], label=lib_labels, **h_kwargs)
ax.hist([f32t, f32], label=lib_labels, **h_kwargs)
ax.set_title('Functions')
ax.set_ylabel('Number of Symbols')
#ax.text(0.45, 0.6, change_in_size(f32, f64), transform=ax.transAxes)
ax.text(0.45, 0.6, change_in_size(f32, f32t), transform=ax.transAxes)
ax = axs[1]
#ax.hist([o64, o32], label=lib_labels, **h_kwargs)
ax.hist([o32t, o32], label=lib_labels, **h_kwargs)
ax.set_title('Objects')
ax.set_ylabel('Number of Symbols')
#ax.text(0.45, 0.6, change_in_size(o32, o64), transform=ax.transAxes)
ax.text(0.45, 0.6, change_in_size(o32, o32t), transform=ax.transAxes)
for ax in np.ravel(axs):
ax.grid(), ax.legend(), ax.semilogx(), ax.set_xlabel('Symbol Size in Bytes')
plt.tight_layout()
#f_lgw = {'Local': [fl64, fl32], 'Global': [fg64, fg32], 'Weak': [fw64, fw32]}
#o_lgw = {'Local': [ol64, ol32], 'Global': [og64, og32], 'Weak': [ow64, ow32]}
f_lgw = {'Local': [fl32t, fl32], 'Global': [fg32t, fg32], 'Weak': [fw32t, fw32]}
o_lgw = {'Local': [ol32t, ol32], 'Global': [og32t, og32], 'Weak': [ow32t, ow32]}
#f_lgwr = {'Local': [fl64r, fl32r], 'Global': [fg64r, fg32r], 'Weak': [fw64r, fw32r]}
#o_lgwr = {'Local': [ol64r, ol32r], 'Global': [og64r, og32r], 'Weak': [ow64r, ow32r]}
f_lgwr = {'Local': [fl32rt, fl32r], 'Global': [fg32rt, fg32r], 'Weak': [fw32rt, fw32r]}
o_lgwr = {'Local': [ol32rt, ol32r], 'Global': [og32rt, og32r], 'Weak': [ow32rt, ow32r]}
fig, axs = plt.subplots(4, 3, figsize=(8,12), sharey=True)#'row')#, gridspec_kw=dict(wspace=0))
for indx, (symlabel, symbols) in enumerate(f_lgw.items()):
ax = axs[0, indx]
ax.hist(symbols, label=lib_labels, **h_kwargs)
ax.set_title(symlabel)
ax.set_ylabel('Functions') if indx == 0 else None
for indx, (symlabel, symbols) in enumerate(f_lgwr.items()):
ax = axs[1, indx]
ax.hist(symbols, label=lib_labels, **h_kwargs)
ax.set_title(symlabel)
ax.set_ylabel('Functions, ROOT Related') if indx == 0 else None
for indx, (symlabel, symbols) in enumerate(o_lgw.items()):
ax = axs[2, indx]
ax.hist(symbols, label=lib_labels, **h_kwargs)
ax.set_title(symlabel)
ax.set_ylabel('Objects') if indx == 0 else None
for indx, (symlabel, symbols) in enumerate(o_lgwr.items()):
ax = axs[3, indx]
ax.hist(symbols, label=lib_labels, **h_kwargs)
ax.set_title(symlabel)
ax.set_ylabel('Objects, ROOT Related') if indx == 0 else None
for ax in np.ravel(axs):
ax.grid(), ax.legend(), ax.semilogx(), ax.set_xlabel('Symbol Size in Bytes')
plt.tight_layout()
df[['cf', 'r']].agg(['value_counts'])
df[['entry_st_info_type', 'entry_st_info_bind']].agg(['value_counts'])
#section_names = [ (s.name, s['sh_type']) for s in elf32.iter_sections() if s.name and 'SYM' in s['sh_type']]
#section_names
#sections = [s for s in elf32.iter_sections() if s.name]
#sections
#load_segments = [s for s in elf32.iter_segments() if s.header.p_type == 'PT_LOAD']
#load_segments
#seg_sec = [(seg_indx, sec.name, sec['sh_type']) for seg_indx, seg in enumerate(load_segments) for sec in sections if seg.section_in_segment(sec)]
#seg_sec
#symbols = [sym for sym in elf32.get_section_by_name('.symtab').iter_symbols()]
#len(symbols)
##symbols