問題描述
1)我們知道,map() 和reduce() 沒有副作用.如今,我們在手機(jī)上也有多核.那么使用它們是否更有效?
1)As we know, there's no side-effect with map() and reduce(). Nowadays, we also have muti-core on cell phone. So is it more efficient to use them?
2)另一方面,在大多數(shù)瀏覽器上只有一個 js 線程可以執(zhí)行.所以map()和reduce()是為服務(wù)端腳本準(zhǔn)備的?
2)On the other hand, there's only 1 thread for js to execute on most of the browsers. Therefor map() and reduce() are prepared for server-side scripting?
推薦答案
這很容易被忽視,但獲得 MapReduce 好處的關(guān)鍵在于
It is easily overlooked, but the key to getting the benefits of MapReduce is to
A) 利用優(yōu)化的隨機(jī)播放.通常,您的 map 和 reduce 函數(shù)可以用慢速語言實(shí)現(xiàn),只要 shuffle(最昂貴的操作)得到很好的優(yōu)化,它仍然是快速且可擴(kuò)展的.
A) Exploit the optimized shuffle. Often, your map and reduce functions can be implemented in a slow language, as long as the shuffle - the most expensive operation - is well optimized, it will still be fast and scalable.
B) 利用檢查點(diǎn)功能從節(jié)點(diǎn)故障中恢復(fù)(但希望您的 CPU 內(nèi)核不會出現(xiàn)故障).
B) Exploit the checkpointing functionality to recover from node failures (but hopefully, your CPU cores won't fail).
所以說到底,map-reduce 實(shí)際上既不是 map,也不是 reduce 函數(shù).這是關(guān)于它周圍的框架;即使使用糟糕的map"和reduce"功能,它也會為您提供良好的性能(除非您在 shuffle 步驟中失去對數(shù)據(jù)集大小的控制!).
So in the end, map-reduce is actually neither about the map, nor the reduce functions. It's about the framework around it; which will give you good performance even with bad "map" and "reduce" functions (unless you lose control over your data set size in the shuffle step!).
在單個節(jié)點(diǎn)上執(zhí)行多線程 map-reduce 所獲得的收益相當(dāng)?shù)?,并且很可能?比 map-reduce 更好的方法來為共享內(nèi)存架構(gòu)并行化您的商店強(qiáng)>...
The gains to be obtained from doing a multi-threaded map-reduce on a single node are fairly low, and most likely there are much better ways of parallelizing your shop for shared memory architectures than map-reduce...
不幸的是,現(xiàn)在圍繞 mapreduce 有很多炒作(而且理解太少).如果您查找 原始論文,它會詳細(xì)介紹備份任務(wù)"、機(jī)器故障"和局部優(yōu)化"(對于內(nèi)存中的單主機(jī)用例,這兩者都沒有意義).
Unfortunately, there is a lot of hype (and too little understanding) surrounding mapreduce these days. If you look up the original paper, it goes into detail about "Backup Tasks", "Machine Failures" and "locality optimization" (neither of which makes sense for an in-memory single-host use case).
僅僅因?yàn)樗幸粋€map"和一個reduce"并不能使它成為一個mapreduce".
如果它具有優(yōu)化的隨機(jī)播放、節(jié)點(diǎn)崩潰和落后者恢復(fù),則它只是一個 MapReduce.
Just because it has a "map" and a "reduce" doesn't make it a "mapreduce" yet.
It's only a MapReduce if it has an optimized shuffle, node crash and straggler recovery.
這篇關(guān)于對于 Array,使用 map() & 是否更有效?在javascript中減少()而不是forEach()?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!