数据流并发的一个很好的激励示例是什么?
我了解数据流编程的基础知识,并且在 Clojure API、Jonas Boner 的演讲、 Groovy 等中的 GPars 我知道它在 Io 等语言中很流行(虽然我没有研究过 Io) 。
我缺少的是在构建并发程序时关心数据流作为范例的令人信服的理由。为什么我要使用数据流模型而不是可变状态+线程+锁模型(常见于 Java、C++ 等)或参与者模型(常见于 Erlang 或 Scala)或其他模型?
特别是,虽然我知道上述语言(以及 Scala 和 Ruby)的库支持,但我不知道有哪个程序或库是该模型的典型用户。谁在使用它?为什么他们发现它比我提到的其他模型更好?
I understand the basics of dataflow programming and have encountered it a bit in Clojure APIs, talks from Jonas Boner, GPars in Groovy, etc. I know it's prevalent in languages like Io (although I have not studied Io).
What I am missing is a compelling reason to care about dataflow as a paradigm when building a concurrent program. Why would I use a dataflow model instead of a mutable state+threads+locks model (common in Java, C++, etc) or an actor model (common in Erlang or Scala) or something else?
In particular, while I know of library support in the languages above (and Scala and Ruby), I don't know of a single program or library that is a poster child user of this model. Who is using it? Why do they find it better than the other models I mentioned?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也有一个错误的例子。它没有实现干净的参与者模型,并且没有并发问题,但它使用 DF 架构,并且极其流行:任何电子表格软件(例如 MS Excel)。
当您修改单元格时,它会向引用它的单元格发送“重新计算”信号。不过,当您处理的工作表变得越来越大时,您可以感受到数据流编程的真正味道 - 工作的重点将发生变化:
如果我们意识到公式是组件,引用是消息,那么我们就得到了数据流编程的常用方法:首先,我们创建一些组件,然后用它们构建数据流图。如果组件太大,我们会将它们分成更小的组件。最后,我们选择一个可视化组件来呈现令人赏心悦目的结果。
I have a wrong example, too. It does not implement a clean actor model, and it has no concurrency issues, but it uses DF architecture, and extremly popular: any spreadsheet software (e.g. MS Excel).
When you modify a cell, it sends "recalculate" signal to the cells which have reference to it. Altough, when you are working with a sheet, which becomes bigger and bigger, you can feel the real taste of the dataflow programming - the focus of the work will change:
If we realise, that formulas are components, and references are messages, we get the usual way of dataflow programming: first, we're creating some components, then we're building a dataflow graph with them. If components are too big, we split them into smaller ones. Finally, we're picking a visualization component for an eye-candy result presentation.
我有一个很好的“典型儿童”(我喜欢这个词)给你。我想,你以前从未见过它,但你可能听说过它。
我认为,几乎所有现代数字合成器和采样器内部都有某种数据流架构。让我告诉你它们是如何工作的。
我不确定 Roland JV-1080 是否是第一个,但它是最著名的具有 4 层声音发生器方案的合成器。当您按下键盘上的某个键时,补丁就会启动。它由1..4个声音发生器组成。声音发生器由一系列组件组成:振荡器、滤波器、包络、放大器。 JV-1080能够同时播放64个声音发生器。有源声音发生器的输出进入效果配置。声音生成器路径是“硬连线”的,您可以选择效果总线的入口点和数量。
Roland JV-1080的效果总线有4个入口点:干、自定义效果、合唱、混响,还有主输出。效果总线是固定的,但所有效果的输出都连接到最右边的所有其他效果,因此您可以通过将数量设置为零来“删除它们之间的连接”。
Alesis QS 系列(QuadraSynth、QS6-7-8-R 和 x.1 版本)具有接近的一些声音架构,效果系统也类似......不同之处在于,您可以从3 FX 配置。一种 FX 配置适用于风琴(QS 具有令人难以置信的 Leslie 仿真):Leslie、Choir、Reverb;另一个 FX 配置有两个混响。您可以更自由地选择如何利用齿轮的马力。
这些合成器很棒,但当您遇到 Clavia Nord Modular 时,您会忘记它们。它没有 4 层架构,也没有 FX 配置。它附带一个 win32 程序、一个数据流编辑器。有各种组件:振荡器、滤波器、包络发生器等,您可以绘制您的配置。您应该画一个传统的 4 层声音发生器,但如果您愿意,您甚至可以画一个 99 层的声音发生器。它只是简单地摇滚。 (不得不说,DF 并不是一切:Roland JV 有 44.1 kHz 采样频率,QS 有 48k,Modular 有 96k。)
Clavia 有另一条合成器系列:Nord Lead。里面有Modular的引擎(参数和声音都一样),但是你不能使用该模型的数据流编程器。它们有固定的路径,有很多参数,但你不能改变路线。此外,还有针对 Modular 的 Nord Lead 补丁集:所有路径在编辑器中看起来都相同,只有参数有所不同。
这是一个模块化补丁示例 http://www.clavia.se/pictures/nordmodular/patchwindowlarge .jpg
如果您对合成示例不满意,比如说,因为您是 C 程序员,那么这里是另一个更熟悉的示例:
make -j
这让我感到惊讶, make是一个数据流系统,因此它可以同时运行“组件”,这意味着在多核机器上编译速度更快。试试吧!
I have a good "poster child" (I like this term) for you. I assume, you have never seen it before, but you've probably heard it.
I think, almost all the modern digital syntehisers and samplers have some kind of dataflow architecture inside. Let me tell you how they work.
I'm not sure if Roland JV-1080 was the first, but it was the most famous synth with 4-layer sound generator scheme. When you press a key on the keyboard, a Patch is starting. It consist of 1..4 sound generator. A sound generator is a line of components: oscillator, filter, envelope, amp. JV-1080 is able to play 64 sound generator at a time. The active sound generators' output goes into the effect configuration. The sound generator path is "hardwired", you can select the entry points of the effect bus, and amounts.
Roland JV-1080's effect bus have 4 entry points: dry, custom effect, choir, reverb, and there is the main output. The effect bus is fixed, but all the effects' output is wired to all other effects, which is standing rightmost to it, so you can "delete connection" between them by setting the amount to zero.
Alesis QS series (QuadraSynth, QS6-7-8-R and x.1 versions) have near some sound architecture, and the effect system is similar... except, that you can choose one from the 3 FX configuration. One FX config is for organs (QS have incredible Leslie emulation): Leslie, Choir, Reverb; another FX config has two Reverbs. You have more freedom on how to utilize the horsepower of the gear.
These synths are great, but you will forget them, as you meet Clavia Nord Modular. It has no 4-layer architecture, nor FX configs. It comes with a win32 program, a dataflow editor. There are various components: oscillators, filters, envelope generators etc., and you can draw your configuration. You should draw a traditional 4-layer sound generator, but you can even draw a 99-layer one, if you want. It just simply rocks. (Has to say, that DF is not everything: Roland JV has 44.1 kHz sample freq, QS has 48k, Modular has 96k.)
Clavia have anoter line of their synths: Nord Lead. There are Modular's engine inside (the parameters and the sound is the very same), but you can't use the dataflow programmer for that models. They have a fixed path, with plenty of parameters, but you can't change the route. Also, there are Nord Lead patch-set for Modular: all the pathces looks same in the editor, only paremeter varies.
Here's a Modular patch example http://www.clavia.se/pictures/nordmodular/patchwindowlarge.jpg
If you are not statisfied by the synth example, say, because you're C programmer, here is another, which is more familiar:
make -j
It was surprise to me, that make is a dataflow system, so it can run "components" simultaneously, which means faster compiling on multi-core machines. Try it!
如果你仔细想想,关系数据库就是典型。考虑任何评估计划,其中每个运算符处理来自其他运算符/表的行流,并生成输入其他运算符的流。
从网络上盗取的随机图像:
(来源:数学上的goldwasser .slu.edu)
If you think about it, relational databases is the poster child. Think of any evaluation plan, where each operator processes streams of rows from others operators/tables and produce streams that are fed into other operators.
Random image stolen off the web:
(source: goldwasser at mathcs.slu.edu)
看看这个: http://www.synthedit.com/
这是一个与音频相关的框架和组件集VSTi。我不知道它到底是如何进行的,但看起来作者发布了带有自己的一组标准组件的软件,然后其他人可以通过编译 DLL 来附加他们的组件。
另外,我刚刚在附近发现了一个人,我们在同一个邮件列表上,他创建了一个漂亮的 TB303 模拟器(著名的模拟复古合成器),并且他使用 SynthEdit 作为框架创建了它。所以,如图所示,它可以用作框架,没有技术(也没有商业模型)困难。
因此,值得一看,我在浏览文档时发现了很好的实现实践。尽管该网站不包含“数据流”一词,并且文档应该进行更好的编辑,但该项目的精神是好的。还有一些“第三方”组件开发人员。它至少有很好的 GUI 前端。
Check this out: http://www.synthedit.com/
It's an audio related framework and component set for VSTi. I don't figured out how it goes exactly, but it looks like the author releases the software with a standard bunch of components of own, then other folks can attach their ones by compiling DLLs.
Also, I've just caught a guy nearby, we're on the same mailing list, who has created a nice TB303 simulator (famous analog vintage synth), and he's created it using SynthEdit as framework. So, as figure shows, it can be used as framework, there is no technical (nor bizmodel) difficulty.
So, it's worth a look, I've found great implementation practices browsing thru the document. Altough, the site does not contain the word dataflow, and the documentation should be better edited, the spirit of the project is OK. There're a couple of "3rd party" component developers, too. It has nice GUI frontend, at not least.