[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

This is an old revision of the document!


Table of Contents

MapReduce Tutorial : Initialization and cleanup of MR tasks

During the mapper or reducer task execution the following steps take place:

The setup and cleanup methods are very useful for initialization and cleanup of the tasks.

Please note that complex initialization should not be performed during construction of Mapper and Reducer objects, as these are constructed every time the script is executed.

Exercise

Improve the wc-without-combiner.pl script by manually combining the results in the Mapper – create a hash of word occurrences, fill it during the map calls and output the (key, value) pairs in cleanup method.

Then measure the improvement.

Solution.pl

Combiners and Perl API performance

As you have seen, the combiners are not efficient when using the Perl API. This is a problem of Perl API – reading and writing the (key, value) pairs is relatively slow and a combiner does not help – it in fact increases the number of (key, value) pairs that need to be read/written.

This is even more obvious with larger input data:

Script Time to complete on /home/straka/wiki/cs-text
wc-without-combiner.pl 5mins, 4sec
wc-with-combiner.pl 5mins, 33sec
wc-with-perl-hash.pl 2mins, 24sec

For comparison, here are times of Java solutions:

Program Time to complete on /home/straka/wiki/cs-text Size of map output
Wordcount without combiner 2mins, 26sec 367MB
Wordcount with combiner 1min, 51sec 51MB
Wordcount with hash in mapper 1min, 14sec 51MB

Using the combiner is beneficial, although manually combining the word occurences in mapper manually is still faster.


[ Back to the navigation ] [ Back to the content ]