为什么不星火使用本地计算机上的所有内核 [英] Why is Spark not using all cores on local machine

查看:149
本文介绍了为什么不星火使用本地计算机上的所有内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行了一些在Spark-Shell或作为作业Apache的星火例子,我不能够实现一台机器上充分利用的核心。例如:

When I run some of the Apache Spark examples in the Spark-Shell or as a job, I am not able to achieve full core utilization on a single machine. For example:

var textColumn = sc.textFile("/home/someuser/largefile.txt").cache()
var distinctWordCount = textColumn.flatMap(line => line.split('\0'))
                             .map(word => (word, 1))
                             .reduceByKey(_+_)
                             .count()

在运行此脚本,我大多只看到1或2我的8芯机上活动核心。
是不是星火应该parallelise呢?

When running this script, I mostly see only 1 or 2 active cores on my 8 core machine. Isn't Spark supposed to parallelise this?

推荐答案

当你运行一个本地的火花外壳,你还必须指定您的火花任务将使用内核的数量。如果你想使用8芯确保您

when you run a local spark shell, you still have to specify the number of cores that your spark tasks will use. if you want to use 8 cores make sure you

export MASTER=local[8]

在运行你的shell。

before running your shell.

此外,作为@zsxwing说,您可能需要确保您的数据被划分成足够的分区,以保持所有内核的忙,或者您指定要查看的并行量。

Also, as @zsxwing says, you may need to ensure that your data is partitioned into enough partitions to keep all of the cores busy, or that you specify the amount of parallelism you want to see.

这篇关于为什么不星火使用本地计算机上的所有内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆