五层协议的网络体系结构要点
This article is a part of the Learning notes series — Computer architecture Essentials, which summarizes some of the key concepts I learnt about Computer architecture. In this article, a gentle introduction of computer architecture and the related performance evaluation metrics will be given.
本文是“学习笔记”系列(“计算机体系结构基础”)的一部分,该系列总结了我从计算机体系结构中学到的一些关键概念。 在本文中,将对计算机体系结构和相关的性能评估指标进行简要介绍。
Computer architecture is a subfield of Computer Engineering that is about balancing the performance, efficiency, cost, and reliability of a computer system. It’s really about making a tradeoff between different factors during the design process in order to build much more advance computer.
计算机体系结构是计算机工程的一个子领域,旨在平衡计算机系统的性能,效率,成本和可靠性。 这实际上是为了在设计过程中对不同因素进行权衡,以便构建更先进的计算机。
Let’s look at the following figure, the layer of abstraction shows that the higher layer has lower complexity and the lower layer has a higher complexity. From my point of view, the focus of computer architecture from assembly language to the logic gate level, sitting at the middle of the abstraction. It implies that this subject cannot be naively classified as belonging to the software domain or the hardware domain, but it is at the intersection point of these two areas, which means that we have to apply the theory and tools in both areas in order to achieve our goal — makes computer BETTER.
让我们看下图,抽象层显示较高的层具有较低的复杂性,较低的层具有较高的复杂性。 从我的角度来看,计算机体系结构的重点从汇编语言到逻辑门级别,都位于抽象的中间。 这意味着该主题不能天真的被归类为属于软件领域或硬件领域,而是处于这两个领域的交汇点,这意味着我们必须在这两个领域中应用理论和工具才能实现我们的目标-使计算机更好。
https://www.secplicity.org/2018/09/19/understanding-the-layers-of-a-computer-system/) https://www.secplicity.org/2018/09/19/understanding-the-layers-of-a-computer-system/ )You may ask what’s the point for me to learn it? I’m a web/mobile/game/… engineer, I don’t do hardware stuff and I don’t like hardware at all. Well, the followings might be the reasons to convince you:
您可能会问我学习的目的是什么? 我是一位网络/手机/游戏/ ...工程师,我不做硬件,也不喜欢硬件。 好吧,以下可能是说服您的原因:
Learning computer architecture gives you a full picture of the world of the computer. It is crucial for a software engineer to have an overview of how your BEST friend — computer, works. As mentioned before, computer architecture is about making a trade-off. As a software engineer, we’re also making a trade-off during the design of software, the overview of the world of computer helps you to make a better decision. 学习计算机体系结构可以使您全面了解计算机世界。 对于软件工程师来说,全面了解您最好的朋友-计算机的工作方式至关重要。 如前所述,计算机体系结构是要进行权衡的。 作为软件工程师,我们还在软件设计过程中做出权衡,因此,计算机世界的概况可以帮助您做出更好的决策。 Having a deeper understanding of the lower-level system allows you to write better code, in term of performance and efficiency. If you understand how the memory works, you can organize your data in the memory such that eventually reduce the overhead of the memory access. With the deep understanding of the computer system in mind, you know how to optimize your code and investigate the bottleneck of your system. 对底层系统有更深入的了解,就性能和效率而言,使您可以编写更好的代码。 如果您了解内存的工作原理,则可以组织内存中的数据,从而最终减少内存访问的开销。 有了对计算机系统的深刻理解,您就会知道如何优化代码并研究系统的瓶颈。 It is FUN and INTERESTING🤣🤣🤣 充满乐趣和趣味🤣🤣🤣Are you curious about how will happen when you perform any operation on the computer? This subject is definitely for you! Let’s start our Journey Now~
您是否对在计算机上执行任何操作时会发生什么感到好奇? 这个主题绝对适合您! 让我们开始旅程吧〜
Computer architecture is about enhancing the performance of the computer system, but what is ‘Performance’? What ‘Performance’ really means? To make our goal clear and specific, we need some sort of scientific tool to quantify the term ‘Performance’.
计算机体系结构与提高计算机系统的性能有关,但是什么是“性能”? “性能”的真正含义是什么? 为了使我们的目标清晰明确,我们需要某种科学工具来量化“绩效”一词。
Generally, there are two types of measure of performance: Latency and Throughput. In Layman’s term, Latency means how much time takes from the task started until it is done. Throughput measure how many tasks can be performed in unit time.
通常,有两种类型的性能度量: 延迟和吞吐量。 用Layman的术语来说,延迟是指从任务开始到完成为止需要多少时间。 吞吐量衡量单位时间内可以执行多少个任务 。
When we compare the performance of two computer systems, we usually say ‘X system is Y times faster than Z system ’. The ‘Y’ in this sentence means the speed-up or the enhanced performance of the computer system. To calculate the speedup/enhanced performance, the following formula can be used:
当我们比较两个计算机系统的性能时,通常会说“ X系统比Z系统快 Y倍”。 这句话中的“ Y”表示计算机系统的加速或增强的性能。 要计算加速/增强性能,可以使用以下公式:
The formula for calculating the speedup between two systems 计算两个系统之间的加速比的公式speedup(X) in this formula can be considered as a function for all performance metric, like speed, throughput, latency and so on, as long as the metrics are directly proportional to the enhanced performance. Therefore, this formula can be applied to throughput but not the latency in our case. The higher the latency, the worse of the performance as it takes more time the complete an operation. To calculate the speedup correctly, the numerator and denominator have to be inverted as latency is inversely proportional to the speedup.
只要性能指标与增强性能成正比 ,该公式中的speedup(X)就可以视为所有性能指标的函数,例如速度,吞吐量,延迟等。 因此,在我们的情况下,此公式可以应用于吞吐量,但不能应用于延迟。 延迟越高,性能越差,因为完成一个操作需要花费更多时间。 为了正确计算加速比,分子和分母必须反转,因为等待时间与加速成反比。
Usually, we want to know how much the system has been enhanced on average based on the result of different applications. The natural way to think about it is to calculate the individual speedup of two systems and average out of it to get the “Average speedup of the system”. However, it is WRONG. The Speedup is a ratio that it cannot be taken an average. It is the correct way to do so:
通常,我们想知道基于不同应用程序的结果平均对系统进行了多少增强。 考虑这一点的自然方法是计算两个系统的单个加速并取其平均值以获得“系统的平均加速”。 但是,这是错误的。 加速比是无法取平均值的比率。 这是正确的方法:
Apply geometric mean of the speedup, the result will be the same as finding the geometric mean of the metric and calculate the speedup between two systems because of the following: 应用加速的几何平均值,由于以下原因,结果将与找到度量的几何平均值并计算两个系统之间的加速相同: The correct way to calculate the average speedup: Using Geometric Mean, where the subscript indicates the applications from 1 to n. A and B indicate two different systems 计算平均加速比的正确方法:使用几何均值,其中下标指示从1到n的应用。 A和B表示两个不同的系统Up to now, we know how to define, compare and summarize the ‘performance’ of a computer system. However, a computer system consists of many components such as Processor, Memory, and Storage. We have more specific metrics to measure the individual component. For the next section, the metric for evaluating the processor will be introduced.
到目前为止,我们知道如何定义,比较和总结计算机系统的“性能”。 但是,计算机系统由许多组件组成,例如处理器,内存和存储。 我们有更具体的指标来衡量各个组成部分。 在下一部分中,将介绍用于评估处理器的指标。
The iron law of performance of a processor is given as follow:
处理器性能的铁定律如下:
The iron law of performance of a processor 处理器性能的铁律We can see that there are three factors that affect the performance of a processor: the number of instruction of the program, clock cycle needed per instruction and time for one clock cycle. The followings are some causes affecting these three factors:
我们可以看到,有三个因素会影响处理器的性能: 程序的指令数量, 每条指令所需的时钟周期以及一个时钟周期的时间 。 以下是影响这三个因素的一些原因:
The number of instructions, related to
指令数,与
Algorithm 算法 Complier technology 编译器技术 Instruction set design 指令集设计The clock cycle per instruction, related to
每个指令的时钟周期,与
Instruction set design 指令集设计 Processor design 处理器设计The clock cycle time, related to
时钟周期时间,与
Processor design 处理器设计 Circuit design 电路设计 Transistor physics 晶体管物理As mentioned above, the field of computer architecture includes the instruction set design and processor design. In term of instruction set design, we can choose complex instruction which leads to fewer instructions to execute but more cycle needed for one instruction. Or simple instruction that gives us more instructions to execute but fewer cycles needed for one instruction.
如上所述,计算机体系结构领域包括指令集设计和处理器设计。 在指令集设计方面,我们可以选择复杂的指令,这会使执行的指令更少,但一条指令需要更多的周期。 或者说一条简单的指令,它使我们可以执行更多指令,但一条指令所需的周期更少。
On the other hand, we can design a processor such that time for one cycle is shorter but more cycles are needed for one instruction. Or making the time for one cycle longer but fewer cycles for an instruction. Again, there is no perfect design and it is really about how to trade-off.
另一方面,我们可以设计一个处理器,以使一个周期的时间较短,但一条指令需要更多的周期。 或延长一个周期的时间,但减少一条指令的周期。 同样,没有完美的设计,这实际上是如何权衡的。
Sometimes, we’ve only improved part of the system and we want to see how much speedup we have made overall. Then, Amdahl’s Law can be used.
有时,我们只改善了系统的一部分,我们想看看整体上有多少加速。 然后,可以使用阿姆达尔定律。
From this formula, we can see that if we fixed the amount of the speed up, the percentage of the execution time affected by this enhancement has a huge impact on the overall speedup. If this percentage is higher, the overall speedup is larger, implied that we shouldn’t spend too much effort on improving small part of execution time — Make the Common Case Fast.
从这个公式中,我们可以看到,如果我们固定了加速的数量,那么受此增强功能影响的执行时间的百分比将对整体加速产生巨大的影响。 如果此百分比更高,则总体提速会更大,这意味着我们不应该花费太多的精力来减少一小部分执行时间— 加快“常见案例”的速度。
In contrast, if we make the small part of the execution too slow, even we make a huge improvement on the larger portion, the overall speedup will eventually dropdown or make no improvement in the best case — Make the Uncommon Case not too Slow.
相反,如果我们使一小部分执行速度太慢,即使我们对较大部分执行了很大的改进,则总体加速最终将下降,或者在最佳情况下没有任何改进- 使罕见情况不太慢。
Finally, the law of diminishing return also holds when we consider the optimization of the processor. When we keep optimizing the larger portion of the execution time, that portion becomes insignificant compare to the overall execution time as it becomes smaller and smaller. As a result, we may only make little improvement or no progress on that portion — Reconsider the optimization target every time.
最后,当我们考虑处理器的优化时,收益递减规律也成立。 当我们继续优化执行时间的较大部分时,该部分与整个执行时间相比变得无关紧要 ,因为它变得越来越小。 结果,我们在那部分上可能只会做很少的改进或没有进展- 每次都要重新考虑优化目标。
The speedup of parallelization. It can be seen that the speedup saturated when more and more processors are used, which means we are just making very little improvement in the overall system 并行化的加速。 可以看出,当使用越来越多的处理器时,加速达到饱和,这意味着我们对整个系统的改进很少The above is the summary of my learning of computer architecture — performance evaluation. If you want a more concise summary, you can have a look with computer architecture section of my notes, which contains all the learning notes I record about computer science and engineering. Feel Free to let me know if there are any mistakes or errors. HAPPY CODING~
以上是我对计算机体系结构的学习总结-性能评估。 如果需要更简洁的摘要,可以查看我的笔记的“计算机体系结构”部分,其中包含我记录的有关计算机科学和工程学的所有学习笔记。 请随时让我知道是否有任何错误或错误。 快乐编码〜
翻译自: https://medium.com/swlh/computer-architecture-essentials-part-i-performance-evaluation-2dbdfd6ee020
五层协议的网络体系结构要点