首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >哪一种处理1TB文件更快:一台机器还是5台联网机器?

哪一种处理1TB文件更快:一台机器还是5台联网机器?
EN

Stack Overflow用户
提问于 2012-07-14 17:50:33
回答 2查看 1.9K关注 0票数 1

哪一种处理1TB文件更快:一台机器还是5台联网机器?(“要处理”指的是查找该1TB文件中出现次数最多的单个UTF-16字符)。数据传输速率为1Gbit/秒,整个1TB文件驻留在一台计算机中,每台计算机都有一个四核CPU。

下面是我尝试使用一个长数组(数组大小为2^16)来跟踪字符计数的问题。这应该适合单台机器的内存,因为2^16x2^3(长的大小)= 2^19 = 0.5MB。任何帮助(链接,评论,建议)将不胜感激。我使用了Jeff引用的延迟时间,我尽了最大努力使用我所知道的最佳近似。最后的答案是:

单机:5.8h(由于磁盘读取速度慢)

5网络机器:7.64小时(由于从磁盘和网络读取)

代码语言:javascript
复制
1) Single Machine
 a) Time to Read File from Disk --> 5.8 hrs
   -If it takes 20ms to read 1MB seq from disk, 
    then to read 1TB from disk takes: 
    20ms/1MB x 1024MB/GB x 1024GB/TB = 20,972 secs 
    = 350 mins = 5.8 hrs 

 b) Time needed to fill array w/complete count data 
    --> 0 sec since it is computed while doing step 1a
    -At 0.5 MB, the count array fits into L2 cache. 
     Since L2 cache takes only 7 ns to access, 
     the CPU can read & write to the count array 
     while waiting for the disk read. 
     Time: 0 sec since it is computed while doing step 1a

 c) Iterate thru entire array to find max count --> 0.00625ms
   -Since it takes 0.0125ms to read & write 1MB from 
    L2 cache and array size is 0.5MB, then the time 
    to iterate through the array is: 
    0.0125ms/MB x 0.5MB = 0.00625ms  

 d) Total Time 
    Total=a+b+c=~5.8 hrs (due to slowness of reading from disk)

2) 5 Networked Machines   
   a) Time to transfr 1TB over 1Gbit/s --> 6.48 hrs
      1TB x 1024GB/TB x 8bits/B x 1s/Gbit 
      = 8,192s = 137m = 2.3hr
      But since the original machine keeps a fifth of the data, it
      only needs to send (4/5)ths of data, so the time required is: 
      2.3 hr x 4/5 = 1.84 hrs
      *But to send the data, the data needs to be read, which
       is (4/5)(answer 1a) = (4/5)(5.8 hrs) = 4.64 hrs
       So total time = 1.84hrs + 4.64 hrs = 6.48 hrs

   b) Time to fill array w/count data from original machine --> 1.16 hrs
      -The original machine (that had the 1TB file) still needs to
       read the remainder of the data in order to fill the array with
       count data. So this requires (1/5)(answer 1a)=1.16 hrs.  
       The CPU time to read & write to the array is negligible, as 
       shown in 1b.      

   c) Time to fill other machine's array w/counts --> not counted   
      -As the file is being transferred, the count array can be 
       computed. This time is not counted. 

   d) Time required to receive 4 arrays --> (2^-6)s
      -Each count array is 0.5MB
       0.5MB x 4 arrays x 8bits/B x 1s/Gbit 
       = 2^20B/2 x 2^2 x 2^3 bits/B x 1s/2^30bits 
       = 2^25/2^31s = (2^-6)s 

   d) Time to merge arrays  
      --> 0 sec(since it can be merge while receiving)

   e) Total time 
      Total=a+b+c+d+e =~ a+b =~ 6.48 hrs + 1.16 hrs = 7.64 hrs 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-14 20:39:14

这不是一个回答,而是一个更长的评论。您错误地计算了频率数组的大小。1 TiB文件包含550个Gsym,因为没有提到它们的预期频率,所以需要至少64位整数的计数数组(即8个字节/元素)。这个频率数组的总大小将是2^16 * 8 = 2^19字节,或者仅仅是512 KiB,而不是4 GiB,因为您已经计算错了。通过1 Gbps链路发送此数据只需≈4.3 ms (如果您使用具有大帧的1500个字节的MTU的以太网上的TCP/IP,协议报头大约占3%,但它们不受广泛支持/)。此外,这个数组大小完全适合CPU缓存。

您严重高估了处理数据和提取频率所需的时间,还忽略了它可以重叠磁盘读取的事实。事实上,更新驻留在CPU缓存中的频率数组是如此之快,以至于计算时间可以忽略不计,因为大多数时间都会重叠缓慢的磁盘读取。但你低估了读取数据所需的时间。即使使用多核CPU,您仍然只有一条通往硬盘的路径,因此仍然需要完整的5.8小时才能读取单机情况下的数据。

事实上,这是一种数据处理,它既不受益于并行网络处理,也不受益于拥有多个CPU内核。这就是为什么超级计算机和其他快速网络处理系统使用分布式并行文件存储,可以提供许多GB/s的综合读写速度。

票数 1
EN

Stack Overflow用户

发布于 2012-07-17 02:20:23

如果源计算机是5的一部分,则只需要发送0.8tb。

--它甚至可能没有意义,将数据发送给其他机器。考虑到这一点:

为了使源机发送数据,必须先命中磁盘,才能将数据读入主存,然后再通过网络发送数据。如果数据已经在主内存中而没有被处理,那么您就是在浪费这个机会。

因此,假设加载到CPU缓存中的比磁盘到内存或网络上的数据便宜得多(这是事实,除非您是在处理外星硬件),那么您最好只在源计算机上这样做,而分散任务的唯一地方就是以分布式的方式创建/填充“文件”。

因此,您应该只计算1Tb文件的磁盘读取时间,而L1/L2缓存和CPU操作的开销很小。高速缓存访问模式是最优的,因为它是连续的,所以您每一段数据只缓存一次错误。

这里的主要问题是,磁盘是压倒一切的主要瓶颈。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11485994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档