top of page

SPO600 Project - Stage 3: Optimization

For stage 3 we will be covering optimization, I am going to identify optimization opportunities in this software. To understand what I am doing here, I recommend reading my stage 1 and stage 2 before starting this post. Stage 1 I did some benchmarking and Stage 2 was all about profiling.


Since we do not have enough time to test my approaches, I am going to list possible case scenarios that I can take to optimize Zopfli and make it a little bit faster.


As I am looking through the different functions and files that Zopfli has, I notice that one of the first steps I can take is to change the data types in some of the functions. Changing the data type can speed up our software since it will be taking less storage capacity.


For example, I can change some of their primary data types so that it takes fewer bytes size. Maybe a simple int can be an unsigned short int. These minor changes might seem like is not that much but it can make the program run faster and maybe more efficient since is taking less space.


Second, I notice that there are many if statements inside and many loops inside each other. These loops can make the program slower since It can take more time for the compiler to process it. Also, I can put into practice code rewriting optimizations which we did cover in one of our lecture classes. This will improve the code and make the performance better.


Besides, I notice that the 4 functions that take the longest time ZopfliUpdateHash, encodeLZ77, ZopfliFindLongestMatch and BoundaryPM can be improved by just changing their data files or just rewriting some parts of the code as I specify at the beginning those are some of the approaches I will take in order to optimize this software.


Another step that I can take is changing the compiler flags. I can use our class lectures or other documentation to guide me to change the compiler flags to make this program faster and better.


In stage 2, I realize that some of the functions differ in % depending on the size of the image which I think is a little bit inconsistent. Sometimes ZopfliUpdateHash takes less % when an image is smaller in size but once the image size gets bigger the time % is more. The same thing happens with ZopfliFindLongestMatch but the other way around the bigger the image the less % time.


These findings made me curious so I took a look into their code functionalities which I found in src/zopfli/lz77.c for ZopfliFindLongestMatch and src/zopfli/hash.c for ZopfliUpdateHash.I did notice that for both of them the functionalities inside their code are similar and I do think that changing their data type and improving the code performance will make it faster. In addition to changing the compiler flags which can improve the software.


To summarize:

1. Change the data file

2. Improve code performance

3. Update compiler flags


If time allows it I will take those 3 approaches to optimize this software. I hope you enjoy reading through my process. This is my last SPO600 post, I learn a lot and it made me appreciate the open-source community. Thank You!


Recent Posts

See All

Summary - Project Stage 2

Stage 2 was all about profiling our project and get an idea of the usage that it is taking the software. To refresh I am working with zopfli which is an open-source from Google. As I already mentioned

Summary - Project Stage 1

How I found this project? I was looking through the participant and project table when I saw one of my classmate's chosen project, I decided to take a look into that Google open-source website and saw

bottom of page