TEZ-4745: Optimize some write paths in UnorderedPartitionedKVWriter - #534
Open
Aggarwal-Raghav wants to merge 3 commits into
Open
TEZ-4745: Optimize some write paths in UnorderedPartitionedKVWriter#534Aggarwal-Raghav wants to merge 3 commits into
Aggarwal-Raghav wants to merge 3 commits into
Conversation
Contributor
Author
|
Before (Using idiv — Check line 459 in github file diff in this PR): After (Using Integer Unsigned SHift Right i.e. iushr — line 466 after this PR.): |
Contributor
Author
|
The performance might not be as distinctive with the jmh but with actual data and in hive query it may have better CPU performance. Used the following to test /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tez.runtime.library.common.writers;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.tez.common.counters.TezCounters;
import org.apache.tez.runtime.api.OutputContext;
import org.apache.tez.runtime.api.OutputStatisticsReporter;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import org.apache.tez.runtime.library.partitioner.HashPartitioner;
import org.jspecify.annotations.NonNull;
import org.openjdk.jmh.annotations.*;
@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 3, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class PerfTestKVWriter {
private UnorderedPartitionedKVWriter kvWriter;
private IntWritable key;
private Text value;
@Setup(Level.Iteration)
public void setup() throws Exception {
OutputContext outputContext = mock(OutputContext.class);
when(outputContext.getUniqueIdentifier()).thenReturn("mock-id");
when(outputContext.getCounters()).thenReturn(new TezCounters());
when(outputContext.getStatisticsReporter()).thenReturn(mock(OutputStatisticsReporter.class));
when(outputContext.getDestinationVertexName()).thenReturn("mock-dest-vertex");
when(outputContext.getTaskVertexName()).thenReturn("mock-task-vertex");
Configuration conf = createConf();
// 512 MB buffer to avoid disk spills during the 1-second iteration
kvWriter = new UnorderedPartitionedKVWriter(outputContext, conf, 10, 512 * 1024 * 1024);
key = new IntWritable(42);
value = new Text("dummy_value");
}
private static @NonNull Configuration createConf() {
Configuration conf = new Configuration();
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_CLASS, IntWritable.class.getName());
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, Text.class.getName());
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, HashPartitioner.class.getName());
conf.setStrings("tez.runtime.framework.local.dirs", "/tmp");
return conf;
}
@Benchmark
public void testWriteHotPath() throws IOException {
kvWriter.write(key, value);
}
} |
|
💔 -1 overall
This message was automatically generated. |
Contributor
Author
|
Requesting review @abstractdog |
|
💔 -1 overall
This message was automatically generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Check TEZ-4745