Java Compiling, Different File Sizes for Same Code?

Discussion in 'Programming' started by LordofLightning, Jul 3, 2018.

  1. So, a while back I was working on making some modifications to TacoSpigot to delete the chunk generator in hopes of making a faster server jar, as the entire world is pre-genned. Though that failed due to the numerous classes that referenced the chunk generator and populator classes, which I unsuccessful attempted to modify.

    While I cried in agony at my failure, I realized that I had exported one my attempts twice, and noticed that the file size for 2 .jars compiled from the exact same code was different. To make sure I compiled the non-modified TacoSpigot jar and PaperSpigot jars. Every time the were 100-50b larger or smaller than their counterpart. To further test it, I ran the same tests on a windows 10 home machine. (Was running 8.1 enterprise) and then on Ubuntu 16.04. Same results, it was about 10kb larger on win10 then my first non-modified jar. On Ubuntu it was 180kb smaller, then I further realized that if I downloaded TacoSpigot b-114 from yives mirror, the file size didn't match up. (Same build all throughout)

    My Questions
    1. Why are they different?
    2a. Will they run faster on the specific device they were compiled on?
    2b. Will they run faster on the specific operating system version they were compiled on? (E.X. Windows 10 pro-1703, Ubuntu 16.04 - Best version, OSX 10.14 - From the future)
    2c. Will they run faster on the operating system they were compiled on? (E.X. Debian, Ubuntu, MacOSX, Windows)
    3. Will there be a noticeable difference on any of the versions from another?

    Edit: Running Eclipse Java Oxygen, March 2018 edition.
     
  2. Check the content of the jars, and if that's not enough, diff the bytecode of the classes and try to find a pattern. It's likely metadata in the jar/classes that makes the difference.
    Javac produces bytecode, which in theory runs equally fast everywhere. How efficient it actually is, only depends on the JRE and the machine, not on the bytecode. (Ignoring the fact that newer javac versions might produce more efficient bytecode, of course)
    See previous answer.
    Repeated question?
    depends on which version you're talking about. Java version, yes, likely. OS, probably, although numbers might be hard to get since there's a lot of noise in data collection (hard to repeat a benchmark of a whole OS in exactly the same conditions.
     
  3. Thank you, now how does one close a thread?