Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
Livid
406.45D
548.51D
V2EX  ›  Linux

用多核 CPU 来加速文本运算

  •  
  •   Livid ·
    PRO
    · Oct 30, 2013 via iPhone · 5406 views
    This topic created in 4764 days ago, the information mentioned may be changed or developed.
    18 replies  •  1970-01-01 08:00:00 +08:00
    luikore
    luikore
    Oct 30, 2013❤️5
    1
    文章展示了 cat 命令的一个常见误用: 没有多个文件却用 cat 连接.
    结果是多产生了一个进程和一个管道.

    正确写法是:
    <some.txt other cmd ...

    像 wc -l 这类命令的瓶颈明显是硬盘, parallel 以后反而比单核的慢.
    Muninn
    Muninn
    Oct 30, 2013
    2
    恩 压缩估计会好很多
    io类的命令,确实很难说
    felix021
    felix021
    Oct 30, 2013
    3
    测试过wc和grep这种非IO密集型的应用,用了parallel以后反而慢了很多很多;bzip2的话性能可以提高好几倍
    oldcai
    oldcai
    PRO
    Oct 30, 2013
    4
    @felix021 wc和grep就是IO密集型吧。bzip2之类的倒是CPU密集型。
    人生何处不相逢啊。。felix021君。。
    felix021
    felix021
    Oct 30, 2013
    5
    @oldcai 嗯,我说反了。。。
    est
    est
    Oct 30, 2013
    6
    @oldcai 一个反例:WinRAR的解压,IO write是瓶颈。
    oldcai
    oldcai
    PRO
    Oct 30, 2013
    7
    @est 嗯,还是得具体分析,针对一般机器和一般压缩算法而言,CPU更容易是瓶颈。
    bombless
    bombless
    Oct 30, 2013
    8
    @luikore 哈哈,的确是。他这种看的很不舒服
    reusFork
    reusFork
    Oct 30, 2013
    9
    确定这样压缩出来的文件还能解压么?
    --pipe
    --spreadstdin
    Spread input to jobs on stdin (standard input). Read a block of data from stdin (standard input) and give one block of data as input to one job.
    luikore
    luikore
    Oct 30, 2013
    10
    @oldcai CPU比IO快多了, 而且多数CPU瓶颈的场景都是用GPU解决的, 3000个核做data parallel比寥寥几个核做task parallel效果好很多...
    guangwong
    guangwong
    Oct 30, 2013
    11
    = = 说真的,单核分析不动了我就不用这些东西分析了,有更垂直的轮子。。。。。
    Ricepig
    Ricepig
    Oct 31, 2013
    12
    @luikore 我以前也是这么想的,直到看到两篇文章。一篇是说gpu做一个算法有多牛逼。另一篇是intel写的,说是你用来比较的cpu上的代码太烂,爷给你写一个,秒杀GPU实现。
    luikore
    luikore
    Oct 31, 2013
    13
    @Ricepig 链接? 估计那个问题不适合并行化或者不是computation bound的问题
    pythonee
    pythonee
    Oct 31, 2013
    14
    @luikore 开头这个小于号是什么原理,这个叫什么?没有见过,望指教
    luikore
    luikore
    Oct 31, 2013
    15
    @pythonee 以文件为命令的输入流, 放前面和放后面一样, 可以和 > 对比想想. man bash 能找到更详细的阐述
    luikore
    luikore
    Oct 31, 2013
    16
    @pythonee bash 的手册里 Redirecting Input 那段
    pythonee
    pythonee
    Oct 31, 2013
    17
    @luikore 这样写的可读性是不是有点差,个人觉得管道容易理解一些啊
    不知道input哪个怎么理解好理解一点
    luikore
    luikore
    Oct 31, 2013
    18
    @pythonee 既然理解了重定向output stream, 为什么不理解重定向input stream...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1926 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 11:48 · PVG 19:48 · LAX 03:48 · JFK 06:48
    ♥ Do have faith in what you're doing.