Hello everyone,
So it has been a long time since I first enroll in this course. I have been able to learn alot of things about software and how it compiled as general. For this course, I will need to choose a project to work with. After a while, I decided to go with json-c, because I have always wanted to work with C language, which is why I choose this project to further improve my skill.
After cloned the project on github with a command so that I can work on it freely.
[haung1@xerxes ~]$ git clone https://github.com/json-c/json-c.git
Cloning into 'json-c'...
remote: Enumerating objects: 121, done.
remote: Counting objects: 100% (121/121), done.
remote: Compressing objects: 100% (83/83), done.
remote: Total 3956 (delta 60), reused 78 (delta 38), pack-reused 3835
Receiving objects: 100% (3956/3956), 2.91 MiB | 13.43 MiB/s, done.
Resolving deltas: 100% (2545/2545), done.
And then created a branch so that it does not mess with the original branch, built the project with the help of the github page, I began to benchmark the app on AArch64 systems with a make test command with CMake.
[haung1@xerxes build-test]$ make test
Running tests...
Test project /home/haung1/json-c/build-test
Start 1: test1
1/21 Test #1: test1 ............................ Passed 1.54 sec
Start 2: test2
2/21 Test #2: test2 ............................ Passed 1.41 sec
Start 3: test4
3/21 Test #3: test4 ............................ Passed 0.26 sec
Start 4: testReplaceExisting
4/21 Test #4: testReplaceExisting .............. Passed 0.23 sec
Start 5: test_cast
5/21 Test #5: test_cast ........................ Passed 0.28 sec
Start 6: test_charcase
6/21 Test #6: test_charcase .................... Passed 0.22 sec
Start 7: test_compare
7/21 Test #7: test_compare ..................... Passed 0.23 sec
Start 8: test_deep_copy
8/21 Test #8: test_deep_copy ................... Passed 0.27 sec
Start 9: test_double_serializer
9/21 Test #9: test_double_serializer ........... Passed 0.23 sec
Start 10: test_float
10/21 Test #10: test_float ....................... Passed 0.24 sec
Start 11: test_int_add
11/21 Test #11: test_int_add ..................... Passed 0.20 sec
Start 12: test_json_pointer
12/21 Test #12: test_json_pointer ................ Passed 0.28 sec
Start 13: test_locale
13/21 Test #13: test_locale ...................... Passed 0.28 sec
Start 14: test_null
14/21 Test #14: test_null ........................ Passed 0.22 sec
Start 15: test_parse
15/21 Test #15: test_parse ....................... Passed 0.28 sec
Start 16: test_parse_int64
16/21 Test #16: test_parse_int64 ................. Passed 0.22 sec
Start 17: test_printbuf
17/21 Test #17: test_printbuf .................... Passed 0.22 sec
Start 18: test_set_serializer
18/21 Test #18: test_set_serializer .............. Passed 0.23 sec
Start 19: test_set_value
19/21 Test #19: test_set_value ................... Passed 0.20 sec
Start 20: test_util_file
20/21 Test #20: test_util_file ................... Passed 0.26 sec
Start 21: test_visit
21/21 Test #21: test_visit ....................... Passed 0.27 sec
100% tests passed, 0 tests failed out of 21
Total Test time (real) = 7.58 sec
After running, I saw that test1 and test2 are 2 file that took the most time to run, means I will focus on optimizing them first. I see that I can improve this application in multiple of ways, which is:
- Altered build options:
I may try some compiler options like -g or -o3 depending on my process, I will adjust it properly. - Code changes to permit better optimization by the compiler and Algorithm improvements: To reduce the runtime and optimize the code, I will apply hoisting, inlining and try strength reduction also for some loop in the code. Even though the owner has already optimized it quite well, I think I can improve it more to give a better runtime. After learning all the techniques in SPO600 course, I believe I can apply my knowledge in this project to improve it.
As I have stated in the beginning, I will try all of my experiment in a different branch to ensure safety. And I will test my code multiple times, compare the original code with mine, make sure the result is not different except for the runtime and more optimize to make it trustworthy. I will update more in my next post. Thank you for reading.