Repository: asterixdb
Updated Branches:
  refs/heads/master 94b141bc5 -> 508f8526c


[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
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2065
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Contrib: Jenkins <[email protected]>
Reviewed-by: Till Westmann <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/508f8526
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/508f8526
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/508f8526

Branch: refs/heads/master
Commit: 508f8526c59a78c8514e5a73bd2310c7f3b27bb6
Parents: 94b141b
Author: Abdullah Alamoudi <[email protected]>
Authored: Tue Oct 10 12:36:06 2017 -0700
Committer: abdullah alamoudi <[email protected]>
Committed: Wed Oct 11 19:31:14 2017 -0700

----------------------------------------------------------------------
 .../parser/test/ParserPerformanceTest.java      | 96 ++++++++++++++++++++
 .../storage/am/lsm/common/impls/LSMHarness.java |  4 +-
 2 files changed, 98 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/508f8526/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ParserPerformanceTest.java
----------------------------------------------------------------------
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..17cd4ab
--- /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 size = " + round + " 
records");
+        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 admParserTime = end - start;
+        System.err.println("Jackson time = " + jacksonTime);
+        System.err.println("AdmParser time = " + admParserTime);
+    }
+
+    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();
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/508f8526/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMHarness.java
----------------------------------------------------------------------
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 1069f8f..1bdd250 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 @@ public class LSMHarness implements ILSMHarness {
                                     }
                                     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

Reply via email to