Concluding Remarks Redis Source Code Reading Lets Us Start Afresh

Concluding Remarks - Redis Source Code Reading Lets Us Start Afresh #

Unconsciously, we have walked together through over three months of time. During this period, we fought side by side, learning and understanding the Redis source code. Compared with the content of the first season, the material we studied this season was indeed more difficult and required you to be able to calm down and delve into it.

First of all, I’d like to thank you for accompanying me all the way. We have come this far together. Creating this series, I have gained a lot and grown a lot myself. So, in the final lesson, I will share with you the three most important insights that I have gained from doing this course. Let’s continue to improve together.

Redis Source Code: Rethinking Your Knowledge System #

To summarize my feelings in one sentence, reading source code has made me feel like “starting from scratch”.

Before diving into the Redis source code, I already had a basic understanding and grasp of Redis’s principles and common backend system designs. I also had some experience in C programming. I believe that my state of mind at that time is similar to yours as you are reading this conclusion.

However, after studying the Redis source code, I found that I have gained new insights in various aspects, such as C language programming techniques, key mechanisms of computer systems, and principles of system design. These new insights stem from learning the design and implementation of Redis source code. And the study of source code itself has provided me with knowledge beyond Redis, benefiting me tremendously.

For instance, when I was learning about operating systems, I learned about inter-process communication methods like message queues, named pipes, unnamed pipes, shared memory, and so on. However, I couldn’t establish an intuitive understanding of these concepts. But when I read the Redis source code, I discovered that Redis extensively uses unnamed pipes for communication between parent and child processes. This immediately added a new understanding of practical development using pipes to my knowledge system, allowing me to have a practical understanding combined with theory.

On the other hand, when I used to implement some data structures and algorithms, I would follow their definitions in textbooks. However, while reading the Redis source code, I realized that there can be differences between theory and practice. For example, Redis implements strings using different data structures based on their lengths, combines two data structures to implement sorted sets, and uses an approximate method for LRU (Least Recently Used) algorithm, among others.

These actual code implementations have given me a new understanding of how theory and practice are connected within my knowledge system. In real-world system development, we often consider constraints such as performance, space, and complexity, and optimize our development based on theoretical foundations. This new understanding has greatly helped me in my subsequent development work, as I consciously identify the constraints faced by the system I am developing and optimize my implementation methods accordingly.

In fact, we can acquire a wealth of knowledge about computer systems from the Redis source code. This new knowledge may not be immediately applicable to our current work, and it may even be replaced or updated in our ongoing learning process. However, we need to understand that the knowledge we gain at a certain stage often forms the foundation for the next stage of knowledge acquisition.

Analyzing source code itself is a process that combines previously learned theories and development knowledge, further deepening our understanding of practical development knowledge. It is a process that leads us from one knowledge to another, and enables us to re-evaluate and reassess our own knowledge system.

Strengthening Your Willpower by Reading Source Code #

Reading source code can be a challenging task, especially when faced with a large codebase. It can often feel overwhelming and difficult to know where to start. Even after understanding the code structure and identifying key functions to focus on, we still need to navigate through complex call relationships and advanced language implementations, all while trying to grasp the developer’s thought process. These hurdles can easily discourage us and make us want to give up.

I have faced these same issues when reading source code. However, I see this process as a way to train my willpower. The more difficult it gets, the more determined I become, and the more I resist the urge to give up.

Although we can cultivate our willpower by persisting in certain activities, the challenge of reading code is greater. This is because code is all about details, and mastering those details requires a great deal of focus, patience, and attention to detail. It’s different from learning concepts or principles, where our minds can often make quick assumptions.

But reading code doesn’t work that way. If we don’t understand a piece of code, we simply don’t understand it, and we can’t rely on assumptions. The only way forward is to continually strive to understand the code, to acknowledge and address our desire to give up and any negative emotions that arise, and to identify the reasons behind them and gradually reduce resistance, as well as increase our psychological threshold for wanting to quit. This is the new challenge to my willpower that reading source code has provided me.

Of course, in addition to willpower, we also need effective methods. I previously read a book called “The Switch of Motivation,” which contained a quote that said, “Motivation isn’t what influences results, it’s science.” So when I read source code, I break down the reading goals into smaller, more achievable targets on a daily and weekly basis. By accumulating small victories over time, I felt a great sense of accomplishment after completing my reading of the main parts of the Redis source code because I achieved what I set out to do.

Furthermore, I have noticed that the willpower I developed while reading source code has had a positive impact on other challenging tasks. It has allowed me to approach these tasks with confidence and determination instead of fear or hesitation. Therefore, I encourage you, when reading source code, not to be intimidated by the code’s complex structure or intricate call relationships. Instead, plan achievable goals and make steady progress in learning the code.

Reshaping Your Work Principles with Source Code #

Previously, I used to have a linear mindset when it came to work. Once I set a goal, I hoped to accomplish it all at once. However, sometimes due to my knowledge and abilities, I would feel confused about how to achieve the goal in one shot.

When reading the Redis source code, I encountered the same dilemma: I was always striving to master the main code and key technologies. However, during the process of reading the source code, I would sometimes forget some of the details I had learned before after reading a portion of the code. Additionally, concepts and methods that were clear during my learning would become blurry after some time.

Later on, while developing a system of my own, I often referred back to the Redis source code. After completing this system, I realized that the Redis code details that had become blurry had now transformed into deeply ingrained memories.

At that moment, I understood that source code reading is never a one-time learning process. On the contrary, the process of reading source code is like the double helix structure of DNA—it is a cyclical upward process. Learning development knowledge and understanding system implementation through source code reading, and then applying the acquired knowledge in my own system development. During the development process, I would once again read the source code, further my learning, and elevate my understanding to a higher level. This process repeats itself, cycling upward.

In fact, our everyday learning and work are very similar to source code reading. It is a cyclical upward process. Many things are not accomplished overnight; we need to go through a process of “cognition, practice, re-cognition, re-practice.” In this process, we will encounter difficulties and gain rewards, but all of these difficulties and rewards lay the foundation for the next round of cognition and practice. Therefore, we should not be discouraged by temporary setbacks, nor should we stagnate due to momentary achievements. Just like the DNA structure of the source of life, we spiral upwards.

Conclusion #

Today happens to be Saturday, marking an end to this season’s courses. However, this ending is not only a conclusion to a stage, but also the beginning of a new one.

In fact, success doesn’t always depend on how much you know, but rather on what you do when facing ignorance. I hope the three points I mentioned about reading source code can provide some guidance for your work and life. When we are learning something unfamiliar, when we are studying a new language, when we encounter various situations in life and must respond on our own, I hope you can draw on the underlying logic of studying source code in order to make better choices.

Lastly, it’s time for us to say goodbye. Once again, thank you for accompanying me on this journey. I believe we have all grown a lot. And from today onwards, we embark on a new journey in our learning. Let us start anew and apply what we have learned.

Lastly, I have prepared a graduation questionnaire for you. I hope you can take two or three minutes to fill it out. I am truly looking forward to hearing your feedback on this course.

Alright, all good things must come to an end, but the pursuit of knowledge has no end. Until we meet again!