日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

特征阻抗输入阻抗输出阻抗_软件阻抗说明

發(fā)布時(shí)間:2023/11/29 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 特征阻抗输入阻抗输出阻抗_软件阻抗说明 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

特征阻抗輸入阻抗輸出阻抗

by Milan Mimica

米蘭·米米卡(Milan Mimica)

軟件阻抗說明 (Software impedance explained)

數(shù)據(jù)處理組件之間的阻抗不匹配 (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。讓我們立即切換到軟件工程術(shù)語:生產(chǎn)者正在調(diào)用使用者的方法。 調(diào)用方法需要有限的時(shí)間。 我們稱此為響應(yīng)時(shí)間或等待時(shí)間 。 生產(chǎn)者可以將任意數(shù)量(但數(shù)量有限)的數(shù)據(jù)傳遞給每個(gè)方法調(diào)用。 我們稱此為批量大小 。 并發(fā)級別是我們可以使用的另一個(gè)變量。 生產(chǎn)者可以通過限制未決響應(yīng)的窗口大小來控制并發(fā)調(diào)用的數(shù)量。 并發(fā)調(diào)用該方法確實(shí)使吞吐量成倍增長。 吞吐量(T)是窗口大小(W),批處理大小(B)和等待時(shí)間(t)的函數(shù)。

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.

我們的目標(biāo)是最大吞吐量,因此增加并發(fā)性并使用更大的批處理大小。 要是! 響應(yīng)時(shí)間取決于批處理大小和窗口大小。 更正式地說,響應(yīng)時(shí)間是窗口大小和批處理大小的函數(shù)。

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.

為了獲得最大的吞吐量,我們必須找到產(chǎn)生最低t的最高W和B。 非理想的W和B會在組件中引起更高的“阻力”,或者如果您愿意,可以將其稱為背壓 。

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.無論是產(chǎn)生數(shù)據(jù)還是僅傳遞數(shù)據(jù),生產(chǎn)者都必須調(diào)整窗口大小和批處理大小以最適合消費(fèi)者。 否則,我們稱之為軟件阻抗不匹配。

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)沒有通用表達(dá)式,因?yàn)樗Q于組件的實(shí)現(xiàn)。 理論在這里沒有幫助。 您必須用不同的批次和窗口大小來探測使用者,以找出理想的值,這將使吞吐量最大化。

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).

一旦找到理想的批量大小,就必須構(gòu)建一個(gè)“阻抗適配器”。 這是一個(gè)建議的Java實(shí)現(xiàn),該實(shí)現(xiàn)在將項(xiàng)目發(fā)送給下一個(gè)組件之前將其累積并進(jìn)行批處理(為簡便起見,省略了許多樣板代碼)。

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.

請注意,仍然允許使用小于最大(理想)批次大小的使用者。 這樣可以確保不增加額外的延遲。 如果選定的批次大小是最佳的,則假定穩(wěn)定的項(xiàng)目進(jìn)給,調(diào)用消費(fèi)者將花費(fèi)完全的時(shí)間來填充隊(duì)列中的maxBatchSize項(xiàng)目。

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

同樣,可以使用信號量來控制對某個(gè)消費(fèi)者實(shí)例的并發(fā)方法調(diào)用的次數(shù)。

推與拉模式 (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.

上面的場景描述了“推送”模式,在該模式下,生產(chǎn)組件控制調(diào)用,其時(shí)間安排以及提到的關(guān)鍵參數(shù)。 處理背壓的一種更現(xiàn)代的方法是由消耗組件負(fù)責(zé)調(diào)用。 這使系統(tǒng)設(shè)計(jì)人員處在更好的位置,因?yàn)橄慕M件的工程師不需要將批量和窗口大小傳達(dá)給生產(chǎn)者。 然而,需要類似的阻抗適配器。

結(jié)論 (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.

阻抗適配器是有狀態(tài)的組件,由隊(duì)列,線程,回調(diào)映射等組成,這增加了復(fù)雜性,但是匹配阻抗對于組件間的通信至關(guān)重要。

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.

我認(rèn)為每個(gè)組件都應(yīng)指定其阻抗參數(shù):最佳批大小和并發(fā)級別。 這樣生產(chǎn)者的組件可以適應(yīng)以最小化背壓。

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.

與電阻抗不同,軟件中的阻抗不限于二維。 在這里,我僅顯示兩個(gè)參數(shù),但是響應(yīng)時(shí)間通常也取決于其他變量。

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.

阻抗是非常動態(tài)的屬性。 它可能取決于發(fā)送的數(shù)據(jù),總體工作量,有時(shí)甚至取決于調(diào)用者無法控制的變量。 如果需要,消費(fèi)者的API的設(shè)計(jì)方式應(yīng)允許組件通過API發(fā)布其最新的阻抗參數(shù)。 這樣生產(chǎn)者就可以動態(tài)地適應(yīng)。

翻譯自: https://www.freecodecamp.org/news/software-impedance-6796cc65758b/

特征阻抗輸入阻抗輸出阻抗

總結(jié)

以上是生活随笔為你收集整理的特征阻抗输入阻抗输出阻抗_软件阻抗说明的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。