You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Tamas Jambor <ja...@googlemail.com> on 2010/05/05 20:03:21 UTC
mapreduce memory issues
Hi,
I came across a new problem with the mapreduce implementation. I am
trying to optimize the cluster for this implemetation. But the problem
is that in order to run
RecommenderJob-UserVectorToCooccurrenceMapper-UserVectorToCooccurrenceReducer,
I need to set -Xmx2048m, with a smaller value it fails the job. how come
it needs so much memory? maybe there is a memory leak here? generally it
is suggested to set -Xmx512m
the other problem setting it so high is that I have to reduce the number
map/reduce jobs per node, otherwise the next job brings the whole
cluster down.
Tamas
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
I think this must be the issue. But my guess that it is regardless of
the cluster size, because I tried to change the maximum map/reduce task
capacity, and it looks that hadoop does not create more tasks for this
job, even if there are more free slots available.
On 05/05/2010 19:11, Sean Owen wrote:
> I think it's UserVectorToCooccurrenceMapper, which keeps a local count
> of how many times each item has been seen. On a small cluster with a
> few mappers, which see all items, you'd have a count for each item.
> That's still not terrible, but, could take up a fair bit of memory.
>
> One easy solution is to cap its size and throw out low-count entries sometimes.
>
> Just to confirm this is the issue, you could hack in this line:
>
> private void countSeen(Vector userVector) {
> if (indexCounts.size()> 1000000) return;
> ...
>
> That's not a real solution, but an easy way you could perhaps test for
> everyone whether that's the problem. If that's it i can solve this in
> a more robust way.
>
Re: mapreduce memory issues
Posted by Sean Owen <sr...@gmail.com>.
(I committed my proper fix BTW.)
The job itself doesn't override these values. If they're not what you
set, then Hadoop is changing them. I am not entirely familiar with its
rules, but think it limits or alters the number of workers to fit the
distribution of the input, available cores, etc.
On Thu, May 6, 2010 at 12:22 PM, Tamas Jambor <ja...@googlemail.com> wrote:
> I set the default values in mapred-site.xml, but when I run the job and
> check the settings there are different values. I could force to use the
> default values, but that's not optimal either in some cases.
>
> On 06/05/2010 11:36, Sean Owen wrote:
>>
>> Where do you see it setting mappers and reducers? it shouldn't, and
>> doesn't as far as I can see. Hadoop may be overriding your settings.
>>
>
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
I set the default values in mapred-site.xml, but when I run the job and
check the settings there are different values. I could force to use the
default values, but that's not optimal either in some cases.
On 06/05/2010 11:36, Sean Owen wrote:
> Where do you see it setting mappers and reducers? it shouldn't, and
> doesn't as far as I can see. Hadoop may be overriding your settings.
>
Re: mapreduce memory issues
Posted by Sean Owen <sr...@gmail.com>.
Oh duh, I was calling Matcher.matches() instead of Matcher.find(),
which caused it to only match the whole string. I can fix that and
improve this regex, and make the default buffer smaller.
Where do you see it setting mappers and reducers? it shouldn't, and
doesn't as far as I can see. Hadoop may be overriding your settings.
On Wed, May 5, 2010 at 11:11 PM, Tamas Jambor <ja...@googlemail.com> wrote:
> oh ok. this is the problem. I set mapred.child.java.opts to -Xmx1024m, but
> that doesn't match the regex expression, so it sets io.sort.mb to 1000.
> Changing it to -Xmx([0-9]+)m solved the problem.
>
> On 05/05/2010 22:26, Sean Owen wrote:
>>
>> You are welcome to test this by modifying setIOSort() in
>> RecommenderJob. Just crank down that "1000", or divide heapMB by a
>> larger value. This should let you run with somewhat smaller heap
>> sizes. If that's the culprit I'm happy to turn down these values a
>> bit.
>>
>
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
oh ok. this is the problem. I set mapred.child.java.opts to -Xmx1024m,
but that doesn't match the regex expression, so it sets io.sort.mb to
1000. Changing it to -Xmx([0-9]+)m solved the problem.
On 05/05/2010 22:26, Sean Owen wrote:
> You are welcome to test this by modifying setIOSort() in
> RecommenderJob. Just crank down that "1000", or divide heapMB by a
> larger value. This should let you run with somewhat smaller heap
> sizes. If that's the culprit I'm happy to turn down these values a
> bit.
>
Re: mapreduce memory issues
Posted by Ted Dunning <te...@gmail.com>.
Depending on the data, this might be the problem.
It isn't uncommon for there to be some item that all users interact with.
At Veoh, for instance, we had an intro video. This item will naturally
cooccur with all other items and that makes some row of the cooccurrence
matrix be really big.
This usually needs to be dealt with by down-sampling the perverse item.
This has good effects in general, but will make some people's heads explode
on philosophical grounds.
My current theory is that Tamas has just such an item in his data and it
isn't the item counter at all.
On Wed, May 5, 2010 at 2:26 PM, Sean Owen <sr...@gmail.com> wrote:
> Besides
> this little lookup map, the worst thing it does is load a whole row of
> the co-occurrence matrix in memory.
>
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
just one more question on this. It looks like the algorithm overrides
the default values for mapred.map.tasks and mapred.reduce.tasks. how did
you decide on those? it doesn't look optimal.
For example for job
RecommenderJob-IdentityMapper-AggregateAndRecommendReducer
it sets mapred.map.tasks to 145 and mapred.reduce.tasks to just 1...
Re: mapreduce memory issues
Posted by Sean Owen <sr...@gmail.com>.
On Wed, May 5, 2010 at 8:54 PM, Ted Dunning <te...@gmail.com> wrote:
> One big win would be to use Benson's collections instead of a normal map
> (you may already have this).
Of course, already doing so !
> Another problem is the expectation that a map-reduce should be happy with
> 500MB of memory. I don't think that is a universally reasonable
Agree with this sentiment; I might pick a somewhat higher value as the
reasonable max memory for a worker... but I came from Google land
where RAM grows on trees. See below for more on this.
> common than others. Regardless, however, it is reasonable to expect that if
> you see about the same amount of data that you will see about the same
> number of items. In a reasonably scaling system, the amount of data each
> node in the cluster sees will be roughly constant as the input and cluster
> size scale together. In a map-reduce architecture, you even get this
> property if the input size and number of mappers and reducers scale
> together.
... which is the assumption that made me guess this lookup table isn't
going to get big. But if I'm right, it doesn't hurt to cap the size of
the lookup. Which I can commit. But maybe that's not the issue either.
> One observation that makes me suspect that the problem is not the size of
> this table that Sean has mentioned is the fact that Tamas has observed that
> he doesn't get more tasks when he scales the cluster size. That may be that
> Hadoop is happy with the number of splits and has to be forced to split more
> (by setting max split size or number of mappers). The problem might also
> be that this program as designed just needs 3GB to complete and efforts to
> force it into 500MB will always fail.
Tamas, are you configuring the number of mappers and reducers with
command line args? It will not by default run many workers.
I don't know of any stage of this computation that should require
significant memory, so it just can't need this much memory. Besides
this little lookup map, the worst thing it does is load a whole row of
the co-occurrence matrix in memory.
Actually I think I know the answer, perhaps. This is one of two stages
that relies heavily on the combiner for efficiency. It sets io.sort.mb
(the size of the buffer used to hold map output records before
combining and spilling to disk) high. I suspect the issue is here
since it seems to fail when allocating space for the map output
somehow.
Its value is 1000MB, or, if you've set a heap size via
mapred.child.java.opts, half of the heap size you allocate. It
actually does this via a crude regex looking for "Xmx[0-9]+m" in the
string.
So I can imagine that if you don't set it, this buffer overruns the
heap. Or if you do set it, low, then other memory usage overruns half
the heap and it fails again at some point.
You are welcome to test this by modifying setIOSort() in
RecommenderJob. Just crank down that "1000", or divide heapMB by a
larger value. This should let you run with somewhat smaller heap
sizes. If that's the culprit I'm happy to turn down these values a
bit.
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
It might not be a reasonable expectation in general, but for this
particular problem I think the amount of memory needed is unreasonable,
since the same recommender without mapreduce is happy with much less memory.
I agree with you, I think the problem is how hadoop splits the task.
> Another problem is the expectation that a map-reduce should be happy with
> 500MB of memory. I don't think that is a universally reasonable
> expectation. The real expectation for scalable solutions should be that as
> the problem scales, cluster size is allowed to scale, but the size of
> individual cluster members does not increase. It is reasonable to expect
> that if you scale up the problem, but not the number of nodes in the cluster
> that each node may need more and more memory. It is also reasonable to
> expect that the base size of each node may be fairly hefty for some problems
> (as long as it doesn't increase if problemSize / clusterSize is held
> constant).
>
>
Re: mapreduce memory issues
Posted by Ted Dunning <te...@gmail.com>.
On Wed, May 5, 2010 at 11:11 AM, Sean Owen <sr...@gmail.com> wrote:
> I think it's UserVectorToCooccurrenceMapper, which keeps a local count
> of how many times each item has been seen. On a small cluster with a
> few mappers, which see all items, you'd have a count for each item.
> That's still not terrible, but, could take up a fair bit of memory.
>
One big win would be to use Benson's collections instead of a normal map
(you may already have this).
IF this is actually the problem.
Another problem is the expectation that a map-reduce should be happy with
500MB of memory. I don't think that is a universally reasonable
expectation. The real expectation for scalable solutions should be that as
the problem scales, cluster size is allowed to scale, but the size of
individual cluster members does not increase. It is reasonable to expect
that if you scale up the problem, but not the number of nodes in the cluster
that each node may need more and more memory. It is also reasonable to
expect that the base size of each node may be fairly hefty for some problems
(as long as it doesn't increase if problemSize / clusterSize is held
constant).
It is a common to have to deal with items from an large or even apparently
infinite set. This could be words from text, user id's or item id's. The
number of unique items that you will have seen can grow uniformly as you see
more data, but it is a reasonable expectation that some items are much more
common than others. Regardless, however, it is reasonable to expect that if
you see about the same amount of data that you will see about the same
number of items. In a reasonably scaling system, the amount of data each
node in the cluster sees will be roughly constant as the input and cluster
size scale together. In a map-reduce architecture, you even get this
property if the input size and number of mappers and reducers scale
together.
One observation that makes me suspect that the problem is not the size of
this table that Sean has mentioned is the fact that Tamas has observed that
he doesn't get more tasks when he scales the cluster size. That may be that
Hadoop is happy with the number of splits and has to be forced to split more
(by setting max split size or number of mappers). The problem might also
be that this program as designed just needs 3GB to complete and efforts to
force it into 500MB will always fail.
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
yes, I also tried to decrease it until 100, it doesn't make any
difference, still fails.
On 05/05/2010 20:39, Ted Dunning wrote:
> What happens when you decrease the maximum size?
>
> On Wed, May 5, 2010 at 12:21 PM, Tamas Jambor<ja...@googlemail.com>wrote:
>
>
>> it added that extra line, but it still fails there. this is the stack, not
>> sure if it is any use:
>>
>>
>
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
I also tried to increase the number of tasks hadoop creates from 2 to
20. It still fails...
Re: mapreduce memory issues
Posted by Ted Dunning <te...@gmail.com>.
What happens when you decrease the maximum size?
On Wed, May 5, 2010 at 12:21 PM, Tamas Jambor <ja...@googlemail.com>wrote:
> it added that extra line, but it still fails there. this is the stack, not
> sure if it is any use:
>
Re: mapreduce memory issues
Posted by Tamas Jambor <ja...@googlemail.com>.
it added that extra line, but it still fails there. this is the stack,
not sure if it is any use:
2010-05-05 19:28:42,621 INFO org.apache.hadoop.metrics.jvm.JvmMetrics: Initializing JVM Metrics with processName=MAP, sessionId=
2010-05-05 19:28:42,747 INFO org.apache.hadoop.mapred.MapTask: numReduceTasks: 1
2010-05-05 19:28:42,753 INFO org.apache.hadoop.mapred.MapTask: io.sort.mb = 1000
2010-05-05 19:28:42,846 FATAL org.apache.hadoop.mapred.TaskTracker: Error running child : java.lang.OutOfMemoryError: Java heap space
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.<init>(MapTask.java:781)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:350)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:307)
at org.apache.hadoop.mapred.Child.main(Child.java:170)
On 05/05/2010 19:11, Sean Owen wrote:
> I think it's UserVectorToCooccurrenceMapper, which keeps a local count
> of how many times each item has been seen. On a small cluster with a
> few mappers, which see all items, you'd have a count for each item.
> That's still not terrible, but, could take up a fair bit of memory.
>
> One easy solution is to cap its size and throw out low-count entries sometimes.
>
> Just to confirm this is the issue, you could hack in this line:
>
> private void countSeen(Vector userVector) {
> if (indexCounts.size()> 1000000) return;
> ...
>
> That's not a real solution, but an easy way you could perhaps test for
> everyone whether that's the problem. If that's it i can solve this in
> a more robust way.
>
> On Wed, May 5, 2010 at 7:03 PM, Tamas Jambor<ja...@googlemail.com> wrote:
>
>> Hi,
>>
>> I came across a new problem with the mapreduce implementation. I am trying
>> to optimize the cluster for this implemetation. But the problem is that in
>> order to run
>> RecommenderJob-UserVectorToCooccurrenceMapper-UserVectorToCooccurrenceReducer,
>> I need to set -Xmx2048m, with a smaller value it fails the job. how come it
>> needs so much memory? maybe there is a memory leak here? generally it is
>> suggested to set -Xmx512m
>>
>> the other problem setting it so high is that I have to reduce the number
>> map/reduce jobs per node, otherwise the next job brings the whole cluster
>> down.
>>
>> Tamas
>>
>>
>>
Re: mapreduce memory issues
Posted by Sean Owen <sr...@gmail.com>.
I think it's UserVectorToCooccurrenceMapper, which keeps a local count
of how many times each item has been seen. On a small cluster with a
few mappers, which see all items, you'd have a count for each item.
That's still not terrible, but, could take up a fair bit of memory.
One easy solution is to cap its size and throw out low-count entries sometimes.
Just to confirm this is the issue, you could hack in this line:
private void countSeen(Vector userVector) {
if (indexCounts.size() > 1000000) return;
...
That's not a real solution, but an easy way you could perhaps test for
everyone whether that's the problem. If that's it i can solve this in
a more robust way.
On Wed, May 5, 2010 at 7:03 PM, Tamas Jambor <ja...@googlemail.com> wrote:
> Hi,
>
> I came across a new problem with the mapreduce implementation. I am trying
> to optimize the cluster for this implemetation. But the problem is that in
> order to run
> RecommenderJob-UserVectorToCooccurrenceMapper-UserVectorToCooccurrenceReducer,
> I need to set -Xmx2048m, with a smaller value it fails the job. how come it
> needs so much memory? maybe there is a memory leak here? generally it is
> suggested to set -Xmx512m
>
> the other problem setting it so high is that I have to reduce the number
> map/reduce jobs per node, otherwise the next job brings the whole cluster
> down.
>
> Tamas
>
>