Aggarwal-Raghav commented on PR #534:
URL: https://github.com/apache/tez/pull/534#issuecomment-5399835249
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
```java
/*
* 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);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]