Reduce empezando antes que termine Map

En los gráficos que ilustran las implementaciones MapReduce podemos ver una «barrera» entre la fase Map y la Reduce. Una «barrera» es un mecanismo de sincronización entre procesos que espera a que todos los procesos de un lado de la barrera terminen antes que empiecen los procesos del otro lado. En este caso, eso significa que la fase Map debe terminar antes que empiece la fase Reduce. Este comportamiento parece no verse plasmado en Hadoop, en donde podemos ver que la fase Reduce empieza antes que terminen los Maps. Por ejemplo:

09/11/14 10:58:50 INFO mapred.JobClient: map 79% reduce 18%
09/11/14 10:58:54 INFO mapred.JobClient: map 79% reduce 19%
09/11/14 10:58:55 INFO mapred.JobClient: map 80% reduce 19%
09/11/14 10:58:58 INFO mapred.JobClient: map 80% reduce 20%
09/11/14 10:59:00 INFO mapred.JobClient: map 81% reduce 20%
09/11/14 10:59:04 INFO mapred.JobClient: map 82% reduce 20%
09/11/14 10:59:05 INFO mapred.JobClient: map 82% reduce 21%
09/11/14 10:59:08 INFO mapred.JobClient: map 82% reduce 22%

Recientemente, en un thread en la lista common-user de Hadoop se justificó muy bien este comportamiento.

David Howell dijo: «The first 2/3 of the reduce phase (as reported by the progress meters) are all about getting the map results from the map tasktracker to the reduce tasktracker and sorting them. The real reduce happens in the last third, and that part won’t start until all of the maps are done. »

Kevin Weil (líder del equipo de Analytics de Twitter) dijo: «The first third of the reduce phase is really the shuffle, where map outputs get sent to and collected at their respective refucers. You’ll see this transfer happening, and the «reduce» creeping up towards 33%, towards the end of your map phase.  The 33% mark is where the real barrier is.»

Lo que quiere decir que la fase Reduce no empieza realmente hasta que termina la fase Map. Ese porcentaje de «Reduce» que se ve avanzando en paralelo con los Maps, en realidad es la llamada fase de «Shuffle and Sort» que copia y ordena los valores intermedios generados por los Mappers antes de que puedan ser procesados por los Reducers.

Tags:

Leave a Reply