SPO PROJECT - STAGE 3




Hi everyone, for this blog i am going to attempt or figure out a way to optimize the code in the Zopli program.After profiling in stage 2 i found out that the function that was taking up the majority of the run time for the program was called ZopliUpdateHash(). Since this was taking up a bulk of the time iI decided that this function was the first thing that needed to be optimized since it would have the largest affect. This function can be found under the file named "hash.c" and looks like this.





Aside from this function I did look around for other functions to see if there was anything else i could optimize. After looking for about 15 minutes I noticed that the code was well written and it well documented on the Github. If it was'nt for the documentation I probably would'nt even know what half of that code did.

During this stage I had encountered a bunch of problems, Nothing I did worked for the most part. The first thing I did was change the GCC options. the options I tried were O1, O2, O3, and Ofast. Normally I would use O3 since the program works best with it. This time i tried to use Ofast also but for the most part it did'nt do much. As far as I could tell there was'nt a significant change in the timings.

After this didnt work I tried to change the code. After roughly an hour of trying this didnt work either.  For example, in the while loop code, (pos + amount +1) is evaluated twice. You can change the code to make it only evaluate once. Technically it should make the program run faster since it has one less calculation to do every time it loops but it barely puts a dent in the timing. I dont think i can make any significant optimization for this program.

I think the code is optimized as much as it can be in my opinion. According to the website this program is designed to take long. The longer time it takes to run, the better the compression is. While I did change some code around which caused it to be faster, I dont know if this affects how the compression is. This program chooses to have better file compression over time.


Comments

Popular posts from this blog

SPO PROJECT - STAGE 2

Lab 4

Lab 3 - Continued