Variability in Pack size with optimised code
Posted: Tue Apr 16, 2024 5:20 pm
Hi all,
I have code that, amongst other things, creates a pack file (with UseLZMAPacker()), and I noticed that with 6.10, the size of the resulting pack file does not seem to be deterministic. That is, I can run the same code multiple times against the same files, and get slightly different sized output files each time.
After a bit of poking around, this seems to be a side effect of enabling "Optimise generated code" in the compiler options. But the resulting variation happens at runtime, not at compile time (that is, compiling an exe and running the exe multiple times gives different results).
It also seems to require more than one file being added to the pack.
E.g. some example code:
Running this a few times gives:
As far as I can tell, the resulting files are all valid and unpack correctly, so this isn't necessarily a problem, but it's something else that came up as an unexpected discrepancy when checking that newer code matched the output of older code.
This effect is reproducible with either backend. Is this expected behaviour?
I have code that, amongst other things, creates a pack file (with UseLZMAPacker()), and I noticed that with 6.10, the size of the resulting pack file does not seem to be deterministic. That is, I can run the same code multiple times against the same files, and get slightly different sized output files each time.
After a bit of poking around, this seems to be a side effect of enabling "Optimise generated code" in the compiler options. But the resulting variation happens at runtime, not at compile time (that is, compiling an exe and running the exe multiple times gives different results).
It also seems to require more than one file being added to the pack.
E.g. some example code:
Code: Select all
UseLZMAPacker()
Define.i pkhnd
pkhnd=CreatePack(#PB_Any, "C:\Temp\TestPack_"+Str(Random(100))+".lzma")
If pkhnd
AddPackFile(pkhnd, "C:\Program Files\PureBasic\Purebasic.exe", "Purebasic.exe")
AddPackFile(pkhnd, "C:\Program Files\PureBasic\Purebasic.chm", "Purebasic.chm")
ClosePack(pkhnd)
EndIf
Code: Select all
16/04/2024 16:52 7,975,393 TestPack_1.lzma
16/04/2024 16:46 7,975,391 TestPack_40.lzma
16/04/2024 16:49 7,975,390 TestPack_73.lzma
16/04/2024 16:45 7,975,392 TestPack_8.lzma
This effect is reproducible with either backend. Is this expected behaviour?