特征阻抗輸入阻抗輸出阻抗_軟件阻抗說明

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

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發布其最新的阻抗參數。 這樣生產者就可以動態地適應。

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

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391535.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391535.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391535.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

數學建模3

數學建模3 轉載于:https://www.cnblogs.com/Forever77/p/11423169.html

leetcode 190. 顛倒二進制位(位運算)

顛倒給定的 32 位無符號整數的二進制位。 提示: 請注意,在某些語言(如 Java)中,沒有無符號整數類型。在這種情況下,輸入和輸出都將被指定為有符號整數類型,并且不應影響您的實現,因…

JAVA基礎——時間Date類型轉換

在java中有六大時間類,分別是: 1、java.util包下的Date類, 2、java.sql包下的Date類, 3、java.text包下的DateFormat類,(抽象類) 4、java.text包下的SimpleDateFormat類, 5、java.ut…

LeetCode第五天

leetcode 第五天 2018年1月6日 22.(566) Reshape the Matrix JAVA class Solution {public int[][] matrixReshape(int[][] nums, int r, int c) {int[][] newNums new int[r][c];int size nums.length*nums[0].length;if(r*c ! size)return nums;for(int i0;i<size;i){ne…

matplotlib可視化_使用Matplotlib改善可視化設計的5個魔術技巧

matplotlib可視化It is impossible to know everything, no matter how much our experience has increased over the years, there are many things that remain hidden from us. This is normal, and maybe an exciting motivation to search and learn more. And I am sure …

adb 多點觸碰_無法觸及的神話

adb 多點觸碰On Twitter, in Slack, on Discord, in IRC, or wherever you hang out with other developers on the internet, you may have heard some formulation of the following statements:在Twitter上&#xff0c;在Slack中&#xff0c;在Discord中&#xff0c;在IRC…

robot:循環遍歷數據庫查詢結果是否滿足要求

使用list類型變量{}接收查詢結果&#xff0c;再for循環遍歷每行數據&#xff0c;取出需要比較的數值 轉載于:https://www.cnblogs.com/gcgc/p/11424114.html

leetcode 74. 搜索二維矩陣(二分)

編寫一個高效的算法來判斷 m x n 矩陣中&#xff0c;是否存在一個目標值。該矩陣具有如下特性&#xff1a; 每行中的整數從左到右按升序排列。 每行的第一個整數大于前一行的最后一個整數。 示例 1&#xff1a; 輸入&#xff1a;matrix [[1,3,5,7],[10,11,16,20],[23,30,34…

rm命令

命令 ‘rm’ &#xff08;remove&#xff09;&#xff1a;刪除一個目錄中的一個或多個文件或目錄&#xff0c;也可以將某個目錄及其下屬的所有文件及其子目錄均刪除掉 語法&#xff1a;rm&#xff08;選項&#xff09;&#xff08;參數&#xff09; 默認會提示‘是否’刪除&am…

javascript消除字符串兩邊空格的兩種方式,面向對象和函數式編程。python oop在調用時候的優點...

主要是javascript中消除字符串空格&#xff0c;比較兩種方式的不同 //面向對象&#xff0c;消除字符串兩邊空格 String.prototype.trim function() { return this.replace(/(^\s*)|(\s*$)/g, ""); };//去左右空格的函數; function trim(s){return s.replace(/(^\s*)…

如何使用Retrofit,OkHttp,Gson,Glide和Coroutines處理RESTful Web服務

Kriptofolio應用程序系列-第5部分 (Kriptofolio app series — Part 5) These days almost every Android app connects to internet to get/send data. You should definitely learn how to handle RESTful Web Services, as their correct implementation is the core knowle…

leetcode 90. 子集 II(回溯算法)

給你一個整數數組 nums &#xff0c;其中可能包含重復元素&#xff0c;請你返回該數組所有可能的子集&#xff08;冪集&#xff09;。 解集 不能 包含重復的子集。返回的解集中&#xff0c;子集可以按 任意順序 排列。 示例 1&#xff1a; 輸入&#xff1a;nums [1,2,2] 輸…

robot:linux下安裝robot環境

https://www.cnblogs.com/lgqboke/p/8252488.html 轉載于:https://www.cnblogs.com/gcgc/p/11425588.html

感知器 機器學習_機器學習感知器實現

感知器 機器學習In this post, we are going to have a look at a program written in Python3 using numpy. We will discuss the basics of what a perceptron is, what is the delta rule and how to use it to converge the learning of the perceptron.在本文中&#xff0…

JS解析格式化Json插件,Json和XML互相轉換插件

Json對象轉換為XML字符串插件 http://www.jsons.cn/Down/jquery.json2xml.js var xml_content $.json2xml(json_object);XML字符串轉換為Json對象插件 http://www.jsons.cn/Down/jquery.xml2json.js var json_obj $.xml2json(xml_content);json序列化和反序列化方法插件 …

Python之集合、解析式,生成器,函數

一 集合 1 集合定義&#xff1a; 1 如果花括號為空&#xff0c;則是字典類型2 定義一個空集合&#xff0c;使用set 加小括號使用B方式定義集合時&#xff0c;集合內部的數必須是可迭代對象&#xff0c;數值類型的不可以 其中的值必須是可迭代對象&#xff0c;其中的元素必須是可…

深度神經網絡課程總結_了解深度神經網絡如何工作(完整課程)

深度神經網絡課程總結Even if you are completely new to neural networks, this course from Brandon Rohrer will get you comfortable with the concepts and math behind them.即使您是神經網絡的新手&#xff0c;Brandon Rohrer的本課程也會使您熟悉其背后的概念和數學。 …

leetcode 1006. 笨階乘

通常&#xff0c;正整數 n 的階乘是所有小于或等于 n 的正整數的乘積。例如&#xff0c;factorial(10) 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1。 相反&#xff0c;我們設計了一個笨階乘 clumsy&#xff1a;在整數的遞減序列中&#xff0c;我們以一個固定順序的操作符序列來…

python:如何傳遞一個列表參數

轉載于:https://www.cnblogs.com/gcgc/p/11426356.html

curl的安裝與簡單使用

2019獨角獸企業重金招聘Python工程師標準>>> windows 篇&#xff1a; 安裝篇&#xff1a; 我的電腦版本是windows7,64位&#xff0c;對應的curl下載地址如下&#xff1a; https://curl.haxx.se/download.html 直接找到下面的這個版本&#xff1a; curl-7.57.0.tar.g…