abdullah alamoudi has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/2065
Change subject: [NO ISSUE][OTH] Fix memory component release trace call ...................................................................... [NO ISSUE][OTH] Fix memory component release trace call - user model changes: no - storage format changes: no - interface changes: no details: - The trace for releasing memory component produces malformed json which makes it fail to load in chrome tracer. This change fixes it Change-Id: I1bb6105ffebe01b6ece78983b7b56603f0787060 --- A asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ParserPerformanceTest.java M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java 3 files changed, 103 insertions(+), 2 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/65/2065/1 diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ParserPerformanceTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ParserPerformanceTest.java new file mode 100644 index 0000000..569f093 --- /dev/null +++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ParserPerformanceTest.java @@ -0,0 +1,96 @@ +/* + * 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.asterix.external.parser.test; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CoderResult; +import java.nio.charset.StandardCharsets; + +import org.apache.asterix.external.input.record.CharArrayRecord; +import org.apache.asterix.external.parser.ADMDataParser; +import org.apache.asterix.external.util.ExternalDataConstants; +import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; +import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ParserPerformanceTest { + + public void benchmark() throws Exception { + int seed = 2; + int levels = 26; + int[] rounds = getRounds(seed, levels); + for (int round : rounds) { + round(round); + } + } + + private int[] getRounds(int seed, int levels) { + int[] rounds = new int[levels]; + rounds[0] = seed; + for (int i = 1; i < rounds.length; i++) { + seed *= 2; + rounds[i] = seed; + } + return rounds; + } + + public void round(int round) throws Exception { + System.err.println("Running a parse round of " + round + " size"); + ObjectMapper om = new ObjectMapper(); + byte[] json = "{\"name\":\"value\"}".getBytes(StandardCharsets.UTF_8); + long start = System.nanoTime(); + for (int i = 0; i < round; i++) { + om.readTree(json); + } + long end = System.nanoTime(); + long jacksonTime = end - start; + CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder(); + CharBuffer chars = CharBuffer.allocate(ExternalDataConstants.DEFAULT_BUFFER_SIZE); + CharArrayRecord record = new CharArrayRecord(); + set(json, decoder, chars, record); + ADMDataParser parser = new ADMDataParser(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, false); + ArrayBackedValueStorage output = new ArrayBackedValueStorage(); + start = System.nanoTime(); + for (int i = 0; i < round; i++) { + output.reset(); + parser.parse(record, output.getDataOutput()); + } + end = System.nanoTime(); + long cbasTime = end - start; + System.err.println("Jackson time = " + jacksonTime); + System.err.println("Cbas time = " + cbasTime); + } + + private static void set(final byte[] content, final CharsetDecoder decoder, final CharBuffer chars, + final CharArrayRecord record) throws IOException { + chars.clear(); + ByteBuffer bytes = ByteBuffer.wrap(content); + CoderResult result = decoder.decode(bytes, chars, true); + if (result.isError() || (result.isUnderflow() && bytes.remaining() > 0)) { + throw new IOException(result.toString()); + } + chars.flip(); + record.append(chars); + record.endRecord(); + } +} diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java index 1ee68d9..eadebf0 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMMemoryComponent.java @@ -215,4 +215,9 @@ public MemoryComponentMetadata getMetadata() { return metadata; } + + @Override + public String toString() { + return getClass().getSimpleName() + ":" + state; + } } diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java index bc3a5a1..5a2715b 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java @@ -253,8 +253,8 @@ } break; case INACTIVE: - ITracer.check(tracer).instant(lsmIndex.toString(), "release-memory-component", - Scope.p, null); + ITracer.check(tracer).instant(c.toString(), "release-memory-component", Scope.p, + lsmIndex.toString()); ((AbstractLSMMemoryComponent) c).reset(); // Notify all waiting threads whenever the mutable component's has change to inactive. This is important because // even though we switched the mutable components, it is possible that the component that we just switched -- To view, visit https://asterix-gerrit.ics.uci.edu/2065 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1bb6105ffebe01b6ece78983b7b56603f0787060 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: abdullah alamoudi <bamou...@gmail.com>