博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
特征阻抗输入阻抗输出阻抗_软件阻抗说明
阅读量:2522 次
发布时间:2019-05-11

本文共 5014 字,大约阅读时间需要 16 分钟。

特征阻抗输入阻抗输出阻抗

by Milan Mimica

米兰·米米卡(Milan Mimica)

软件阻抗说明 (Software impedance explained)

数据处理组件之间的阻抗不匹配 (The impedance mismatch between data processing components)

It all starts with the simplest signal-processing diagram ever:

一切始于有史以来最简单的信号处理图:

Component A is passing the signal to component B. Let’s switch to software engineering jargon immediately: A producer is invoking a method of a consumer. Invoking a method takes a finite time. We call this response time or latency. The producer can pass an arbitrary (but limited) amount of data to each method invocation. We call this batch size. Concurrency level is another variable we can play with. The producer can control the number of concurrent invocations by limiting the window size of pending responses. Invoking the method concurrently indeed multiplies the throughput. Throughput (T) is a function of window size (W), batch size (B) and latency (t).

组件A将信号传递给组件B。让我们立即切换到软件工程术语:生产者正在调用使用者的方法。 调用方法需要有限的时间。 我们称此为响应时间或等待时间 。 生产者可以将任意数量(但数量有限)的数据传递给每个方法调用。 我们称此为批量大小 。 并发级别是我们可以使用的另一个变量。 生产者可以通过限制未决响应的窗口大小来控制并发调用的数量。 并发调用该方法确实使吞吐量成倍增长。 吞吐量(T)是窗口大小(W),批处理大小(B)和等待时间(t)的函数。

We aim for maximum throughput, so increase the concurrency and use higher batch sizes. If only! Response time depends on batch size and window size. To put it more formally, response time if a function of both window size and batch size.

我们的目标是最大吞吐量,因此增加并发性并使用更大的批处理大小。 要是! 响应时间取决于批处理大小和窗口大小。 更正式地说,响应时间是窗口大小和批处理大小的函数。

To achieve maximum throughput we must find the highest W and B that produce the lowest t. Non-ideal W and B will induce a higher “resistance” in the component, or call it back-pressure if you will.

为了获得最大的吞吐量,我们必须找到产生最低t的最高WB。 非理想的WB会在组件中引起更高的“阻力”,或者如果您愿意,可以将其称为背压

Whether it produces the data or just passing it through, a producer must adapt window size and batch size to best suit the consumer. Otherwise we have what I call software impedance mismatch.
无论是产生数据还是仅传递数据,生产者都必须调整窗口大小和批处理大小以最适合消费者。 否则,我们称之为软件阻抗不匹配。

There is no generic expression for f(W, B) as it depends on the component’s implementation. Theory is of no help here. You have to probe the consumer with different batch and window sizes to spot the ideal values that will maximize the throughput.

f(W,B)没有通用表达式,因为它取决于组件的实现。 理论在这里没有帮助。 您必须用不同的批次和窗口大小来探测使用者,以找出理想的值,这将使吞吐量最大化。

Once you find the ideal batch size you must build an “impedance adapter”. Here is a suggested java implementation that accumulates the items and batches them before sending them to the next component (lots of boilerplate code omitted for brevity).

一旦找到理想的批量大小,就必须构建一个“阻抗适配器”。 这是一个建议的Java实现,该实现在将项目发送给下一个组件之前将其累积并进行批处理(为简便起见,省略了许多样板代码)。

Note that invoking the consumer with smaller than maximum (ideal) batch size is still allowed. This assures no additional latency is added. If the selected batch size is optimal, assuming steady item feed, invoking the consumer will take exactly the time it takes to fill maxBatchSize items in the queue.

请注意,仍然允许使用小于最大(理想)批次大小的使用者。 这样可以确保不增加额外的延迟。 如果选定的批次大小是最佳的,则假定稳定的项目进给,调用消费者将花费完全的时间来填充队列中的maxBatchSize项目。

Likewise, the number of concurrent method invocations towards some consumer instance can be controlled using a semaphore.

同样,可以使用信号量来控制对某个消费者实例的并发方法调用的次数。

推与拉模式 (Push vs. Pull mode)

The above scenario depicts “push” mode, in which the producing component controls the invocation, its timing, and the mentioned key parameters. A more modern approach of dealing with back-pressure is to put the consuming component in charge of the invocation. This puts the system designer in a slightly better position, as engineers of the consuming component don’t need to communicate batch and window size to producers. Nevertheless, a similar impedance adapter is needed.

上面的场景描述了“推送”模式,在该模式下,生产组件控制调用,其时间安排以及提到的关键参数。 处理背压的一种更现代的方法是由消耗组件负责调用。 这使系统设计人员处在更好的位置,因为消耗组件的工程师不需要将批量和窗口大小传达给生产者。 然而,需要类似的阻抗适配器。

结论 (Conclusion)

Impedance adapters are stateful components, consisting of queues, threads, callback maps, etc., which adds complexity, but matching impedance is essential in inter-component communication.

阻抗适配器是有状态的组件,由队列,线程,回调映射等组成,这增加了复杂性,但是匹配阻抗对于组件间的通信至关重要。

I argue that each component should specify its impedance parameters: optimal batch size and concurrency level. That way producer components can adapt to minimize the back-pressure.

我认为每个组件都应指定其阻抗参数:最佳批大小和并发级别。 这样生产者的组件可以适应以最小化背压。

Unlike the electrical impedance, the impedance in software is not limited to two dimensions. Here I show only two parameters, but often the response time depends on other variables too.

与电阻抗不同,软件中的阻抗不限于二维。 在这里,我仅显示两个参数,但是响应时间通常也取决于其他变量。

Impedance is a very dynamic property. It may depend on the data being sent, overall workload, sometimes even on variables not controlled by the caller. If needed, the consumer’s API should be designed in a way that allows the component to publish its latest impedance parameters via API. That way the producers could dynamically adapt.

阻抗是非常动态的属性。 它可能取决于发送的数据,总体工作量,有时甚至取决于调用者无法控制的变量。 如果需要,消费者的API的设计方式应允许组件通过API发布其最新的阻抗参数。 这样生产者就可以动态地适应。

翻译自:

特征阻抗输入阻抗输出阻抗

转载地址:http://zhrwd.baihongyu.com/

你可能感兴趣的文章
标准I/O库之标准I/O的效率
查看>>
JavaCard应用开发环境
查看>>
redis主从复制 从而 数据备份和读写分离
查看>>
聊聊IOCP,聊聊异步编程
查看>>
Java-笔记3-复习
查看>>
MARC
查看>>
LeetCode - 367. Valid Perfect Square
查看>>
剑指offer-二叉树中和为某一值的路径
查看>>
Thinking in Java第十三章学习笔记----字符串
查看>>
从零开始学android开发-获取TextView的值
查看>>
SPSS中八类常用非参数检验之二:二项分布(Binomial)检验
查看>>
并发,并行
查看>>
Luogu 2375 [NOI2014]动物园
查看>>
关于ewebeditor发文时,不能控制行距的问题
查看>>
前端开发者常用的9个JavaScript图表库
查看>>
Centos Apache 多站点配置
查看>>
Perl入门(一)Perl的基本类型及运算符
查看>>
Struts2表单数据接收方式
查看>>
小技巧之a标签自动解析URL
查看>>
51Nod 1099 任务执行顺序 (贪心)
查看>>