Squiblydoo / debloat

A GUI and CLI tool for removing bloat from executables
BSD 3-Clause "New" or "Revised" License
301 stars 25 forks source link

Optimizing the trim_junk function #19

Closed gdesmar closed 10 months ago

gdesmar commented 10 months ago
Keeping in line with my previous PR #18, I was able to figure out how to optimize the trim_junk function. I'm comparing the results for 1.5.0, 1.5.1 and this new branch. The memory is the peak memory used and runs are still in seconds, using the test.py found on PR #18. The sample starting with 49c95279a8 is the only case where it slowed down, but is back to 1.5.0 levels. Sample Size Mem 1.5.0 Mem 1.5.1 Mem New Runs 1.5.0 Runs 1.5.1 Runs new
67b54f7098... 482.577MB 1.884GB 485.421MB 485.421MB [7.35, 5.38, 5.31] [5.08, 6.37, 5.2] [3.65, 3.79, 3.91]
49c95279a8... 100.000MB 595.951MB 495.951MB 102.285MB [0.75, 0.75, 0.76] [0.53, 0.57, 0.54] [0.7, 0.75, 0.67]
f9bf1e1976... 43.152MB 239.493MB 196.341MB 53.014MB [0.34, 0.34, 0.33] [0.24, 0.24, 0.25] [0.2, 0.2, 0.18]
65669e873a... 313.823MB 641.474MB 341.446MB 341.446MB [0.46, 0.44, 0.44] [0.04, 0.04, 0.04] [0.05, 0.04, 0.04]
76f7f979a7... 80.198MB 468.623MB 388.425MB 86.662MB [0.6, 0.6, 0.62] [0.45, 0.46, 0.46] [0.36, 0.36, 0.34]
6a6f3488fa... 31.964MB 187.999MB 156.035MB 41.093MB [0.23, 0.21, 0.2] [0.2, 0.2, 0.18] [0.16, 0.16, 0.16]
90ffb9eade... 353.281MB 2.066GB 1.721GB 355.642MB [2.67, 2.7, 2.57] [2.01, 2.05, 2.05] [1.42, 1.41, 1.44]
36c3216214... 400.000MB 2.343GB 1.952GB 400.617MB [2.85, 2.88, 2.89] [2.38, 2.36, 2.4] [1.66, 1.6, 1.58]
c3bbcf4983... 500.000MB 2.926GB 2.438GB 501.989MB [3.65, 3.72, 4.29] [3.09, 3.05, 3.03] [2.01, 2.03, 2.05]
9892c1e9c8... 302.261MB 1.179GB 306.829MB 306.829MB [5.4, 5.38, 5.38] [4.84, 4.73, 4.78] [4.77, 4.8, 4.76]
c6fda8a049... 302.368MB 1.179GB 307.127MB 307.129MB [5.39, 5.37, 5.54] [5.47, 4.64, 4.74] [4.74, 4.72, 4.78]
9900f584d8... 84.705MB 491.543MB 406.838MB 96.181MB [2.1, 2.1, 2.11] [1.85, 1.74, 1.76] [1.53, 1.48, 1.47]
347248cace... 300.000MB 1.756GB 1.463GB 301.118MB [2.23, 2.21, 2.19] [1.73, 1.71, 1.7] [1.23, 1.19, 1.21]
9adeeeb9e8... 118.460MB 709.387MB 590.927MB 119.495MB [3.56, 3.64, 3.39] [2.88, 2.73, 2.84] [0.5, 0.52, 0.53]
bc1f3d36f8... 35.340MB 206.358MB 171.018MB 38.331MB [0.29, 0.29, 0.29] [0.22, 0.22, 0.22] [0.18, 0.18, 0.17]
b4bd0f0481... 300.000MB 1.755GB 1.462GB 301.391MB [2.17, 2.16, 2.19] [1.58, 1.56, 1.56] [1.24, 1.21, 1.19]
158d07ab61... 39.323MB 182.218MB 39.683MB 39.684MB [1.88, 1.86, 1.9] [1.74, 1.77, 1.78] [1.74, 1.75, 1.71]
Sample Size Mem 1.5.0 Mem 1.5.1 Mem New Runs 1.5.0 Runs 1.5.1 Runs new
NON-Null-Overlay-Random.malz 674.557MB 3.951GB 3.292GB 675.955MB [18.78, 18.11, 18.98] [15.02, 16.14, 16.82] [14.58, 13.95, 14.95]
DotNetResource.malz 307.925MB 1.203GB 308.240MB 308.240MB [3.38, 3.4, 3.43] [2.9, 3.14, 2.97] [2.86, 2.81, 2.91]
Section1.malz 1.264GB 5.057GB 3.793GB 1.265GB [23.39, 23.24, 22.51] [17.58, 17.64, 17.34] [15.72, 15.67, 15.58]
Overlay-NullBytes3.malz 762.939MB 4.416GB 3.671GB 791.046MB [6.13, 5.95, 5.87] [3.78, 3.81, 3.82] [2.9, 2.72, 2.68]
Overlay-AfterSignature2.malz 738.980MB 1.444GB 740.672MB 740.672MB [1.02, 0.98, 0.98] [0.0, 0.0, 0.0] [0.0, 0.0, 0.0]
Themida-Overlay-UnknownFamily.malz 439.726MB 2.574GB 2.144GB 444.907MB [11.51, 11.26, 10.72] [10.79, 9.82, 11.09] [8.88, 8.57, 8.39]
Resource.malz 300.348MB 1.172GB 303.212MB 303.462MB [5.53, 5.48, 5.59] [4.47, 4.47, 4.44] [4.62, 4.56, 4.75]
Section2.malz 709.919MB 4.156GB 3.463GB 711.775MB [12.1, 11.93, 13.27] [8.69, 8.53, 8.55] [7.81, 7.59, 7.59]
OverlayHighCompression.malz 734.451MB 2.867GB 2.148GB 734.524MB [3.31, 3.29, 3.28] [1.14, 1.13, 1.16] [0.06, 0.06, 0.06]
Overlay-NullBytes2.malz 762.939MB 4.409GB 3.664GB 794.584MB [8.46, 5.64, 5.77] [3.82, 3.75, 3.73] [2.84, 2.78, 2.87]
NON-Null-Overlay1.malz 815.940MB 4.737GB 3.940GB 838.728MB [19.47, 19.49, 19.6] [21.4, 20.53, 20.53] [3.13, 3.13, 3.13]
Section-UnknownPacker.malz 705.287MB 4.112GB 3.423GB 705.611MB [12.08, 12.05, 11.85] [9.68, 9.65, 9.58] [7.22, 7.11, 7.28]
Overlay-Random-Chunks.malz 604.650MB 3.542GB 2.951GB 605.308MB [17.75, 17.33, 17.04] [16.12, 16.2, 15.56] [16.6, 17.34, 16.28]
Resource4.malz 300.388MB 1.171GB 305.181MB 305.181MB [4.91, 4.86, 4.85] [4.57, 4.52, 4.62] [4.76, 4.65, 4.73]
Bloat_After_SignatureExample.malz 636.277MB 1.244GB 639.319MB 639.319MB [0.85, 0.82, 0.83] [0.0, 0.0, 0.0] [0.0, 0.0, 0.0]
Packed.malz 726.000MB 2.836GB 2.127GB 728.942MB [7.91, 7.56, 7.08] [6.43, 6.28, 6.58] [6.27, 6.23, 6.25]
Section3.malz 325.880MB 1.887GB 1.568GB 339.685MB [5.93, 5.96, 5.89] [4.55, 4.4, 4.75] [4.13, 4.04, 4.13]
Squiblydoo commented 10 months ago

Merged and released as 1.5.2. (No other changes were introduced in 1.5.2; though I've got my eyes on a few to try to complete soon.)