You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:28:39 UTC

[GitHub] [qpid-dispatch] kgiusti opened a new pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

kgiusti opened a new pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] ted-ross commented on a change in pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
ted-ross commented on a change in pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755#discussion_r436977613



##########
File path: include/qpid/dispatch/iterator.h
##########
@@ -329,6 +329,11 @@ int qd_iterator_ncopy(qd_iterator_t *iter, unsigned char* buffer, int n);
  */
 unsigned char *qd_iterator_copy(qd_iterator_t *iter);
 
+/**

Review comment:
       Is there any reason that the const version shouldn't be the only version?  i.e. add const to the argument of the original function?

##########
File path: include/qpid/dispatch/iterator.h
##########
@@ -329,6 +329,11 @@ int qd_iterator_ncopy(qd_iterator_t *iter, unsigned char* buffer, int n);
  */
 unsigned char *qd_iterator_copy(qd_iterator_t *iter);
 
+/**

Review comment:
       In that case, don't make the change.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] codecov-commenter commented on pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755#issuecomment-640637655


   # [Codecov](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=h1) Report
   > Merging [#755](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=desc) into [master](https://codecov.io/gh/apache/qpid-dispatch/commit/ef80c752dbc167fd7418cc9375b34a917b4f9909&el=desc) will **decrease** coverage by `0.18%`.
   > The diff coverage is `84.10%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/qpid-dispatch/pull/755/graphs/tree.svg?width=650&height=150&src=pr&token=rk2Cgd27pP)](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #755      +/-   ##
   ==========================================
   - Coverage   86.66%   86.48%   -0.19%     
   ==========================================
     Files          96       97       +1     
     Lines       21937    22198     +261     
   ==========================================
   + Hits        19012    19198     +186     
   - Misses       2925     3000      +75     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [tests/parse\_tree\_tests.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-dGVzdHMvcGFyc2VfdHJlZV90ZXN0cy5j) | `61.12% <58.33%> (-0.68%)` | :arrow_down: |
   | [tests/hash\_test.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-dGVzdHMvaGFzaF90ZXN0LmM=) | `77.60% <77.60%> (ø)` | |
   | [src/hash.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL2hhc2guYw==) | `79.12% <84.05%> (+6.09%)` | :arrow_up: |
   | [src/iterator.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL2l0ZXJhdG9yLmM=) | `89.11% <87.50%> (-0.26%)` | :arrow_down: |
   | [src/parse\_tree.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL3BhcnNlX3RyZWUuYw==) | `92.11% <89.60%> (-6.15%)` | :arrow_down: |
   | [src/policy.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL3BvbGljeS5j) | `87.20% <100.00%> (+0.01%)` | :arrow_up: |
   | [tests/run\_unit\_tests.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-dGVzdHMvcnVuX3VuaXRfdGVzdHMuYw==) | `77.77% <100.00%> (+0.85%)` | :arrow_up: |
   | [src/router\_core/transfer.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL3JvdXRlcl9jb3JlL3RyYW5zZmVyLmM=) | `93.50% <0.00%> (-0.97%)` | :arrow_down: |
   | [src/router\_core/forwarder.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL3JvdXRlcl9jb3JlL2ZvcndhcmRlci5j) | `94.11% <0.00%> (-0.66%)` | :arrow_down: |
   | [src/router\_core/core\_client\_api.c](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree#diff-c3JjL3JvdXRlcl9jb3JlL2NvcmVfY2xpZW50X2FwaS5j) | `91.41% <0.00%> (-0.38%)` | :arrow_down: |
   | ... and [10 more](https://codecov.io/gh/apache/qpid-dispatch/pull/755/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=footer). Last update [ef80c75...ff416d2](https://codecov.io/gh/apache/qpid-dispatch/pull/755?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] kgiusti commented on pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
kgiusti commented on pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755#issuecomment-641405559


   **Memory Impact**
   At 40K configured addresses the memory footprint as given via qdstat -m:
   
   **master (pre patch)**
   
     VmSize    Pooled
     464 MiB   66.7 MiB
   
   **DISPATCH-1682**
   
    VmSize     Pooled
     478 MiB   69.0 MiB
   
   478 - 464 = +14MiB
   14/40K = ~+350 bytes per configured address
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] jiridanek commented on a change in pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
jiridanek commented on a change in pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755#discussion_r438895625



##########
File path: tests/hash_test.c
##########
@@ -0,0 +1,257 @@
+/*
+ * 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.
+ */
+
+#include "test_case.h"
+#include <stdio.h>
+#include <string.h>
+#include <qpid/dispatch/iterator.h>
+#include <qpid/dispatch/hash.h>
+
+
+
+static const unsigned char *keys[] = {
+    (const unsigned char *) "/global/foo",
+    (const unsigned char *) "non-address key",
+    (const unsigned char *) "amqp://host/global/sub",
+    (const unsigned char *) "",
+};
+
+static const int key_count = sizeof(keys)/sizeof(keys[0]);
+
+
+// add using iterator key, lookup and remove using string key
+//
+static char *test_iter_keys(void *context)
+{
+
+    qd_hash_handle_t *handles[key_count];
+    qd_hash_t *hash = qd_hash(4, 10, false);
+    if (!hash)
+        return "hash table allocation failed";
+
+    //
+    // add using iterator, lookup and remove using string
+    //
+
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+        qd_hash_handle_t **handle = &handles[i];
+
+        qd_iterator_t *i_key = qd_iterator_string((const char *)key, ITER_VIEW_ALL);
+        if (qd_hash_insert(hash, i_key, (void *)key, handle) != QD_ERROR_NONE)
+            return "hash table insert failed";
+
+        if (strcmp((const char *) qd_hash_key_by_handle(*handle), (const char *)key) != 0)
+            return "hash handle key did not match";
+
+        qd_iterator_free(i_key);
+    }
+
+    if (qd_hash_size(hash) != key_count)
+        return "hash size is incorrect";
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+        unsigned char *value;
+        if (qd_hash_retrieve_str(hash, key, (void **)&value) != QD_ERROR_NONE)
+            return "Key lookup failed";
+        if (strcmp((const char *)value, (const char *)key) != 0)
+            return "key value mismatch";
+    }
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+
+        if (qd_hash_remove_str(hash, key) != QD_ERROR_NONE)
+            return "str key remove failed";
+        qd_hash_handle_free(handles[i]);
+    }
+
+    qd_hash_free(hash);
+    return 0;
+}
+
+
+// add using string key, lookup and remove using iterator key
+//
+static char *test_str_keys(void *context)
+{
+
+    qd_hash_handle_t *handles[key_count];
+    qd_hash_t *hash = qd_hash(4, 10, false);
+    if (!hash)
+        return "hash table allocation failed";
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+        qd_hash_handle_t **handle = &handles[i];
+
+        if (qd_hash_insert_str(hash, key, (void *)key, handle) != QD_ERROR_NONE)
+            return "hash table insert failed";
+
+        if (strcmp((const char *) qd_hash_key_by_handle(*handle), (const char *)key) != 0)
+            return "hash handle key did not match";
+    }
+
+    if (qd_hash_size(hash) != key_count)
+        return "hash size is incorrect";
+
+    for (int i = 0; i < key_count; ++i) {
+        qd_iterator_t *i_key = qd_iterator_string((const char *)keys[i], ITER_VIEW_ALL);
+        unsigned char *value;
+        if (qd_hash_retrieve(hash, i_key, (void **)&value) != QD_ERROR_NONE)
+            return "Iterator key lookup failed";
+        if (strcmp((const char *)value, (const char *)keys[i]) != 0)
+            return "key value mismatch";
+        qd_iterator_free(i_key);
+    }
+
+    for (int i = 0; i < key_count; ++i) {
+        qd_iterator_t *i_key = qd_iterator_string((const char *)keys[i], ITER_VIEW_ALL);
+        if (qd_hash_remove(hash, i_key) != QD_ERROR_NONE)
+            return "str key remove failed";
+        qd_hash_handle_free(handles[i]);
+        qd_iterator_free(i_key);
+    }
+
+    qd_hash_free(hash);
+    return 0;
+}
+
+
+// test lookup and remove failures using iterators
+//
+static char *test_iter_bad(void *context)
+{
+
+    qd_hash_handle_t *handles[key_count];
+    qd_hash_t *hash = qd_hash(4, 10, false);
+    if (!hash)
+        return "hash table allocation failed";
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+        qd_hash_handle_t **handle = &handles[i];
+
+        qd_iterator_t *i_key = qd_iterator_string((const char *)key, ITER_VIEW_ALL);
+        if (qd_hash_insert(hash, i_key, (void *)key, handle) != QD_ERROR_NONE)
+            return "hash table insert failed";
+
+        if (strcmp((const char *) qd_hash_key_by_handle(*handle), (const char *)key) != 0)
+            return "hash handle key did not match";
+
+        qd_iterator_free(i_key);
+    }
+
+    if (qd_hash_size(hash) != key_count)
+        return "hash size is incorrect";
+
+    qd_iterator_t *i_key = qd_iterator_string((const char *)"I DO NOT EXIST", ITER_VIEW_ALL);
+    void *value = (void *)i_key;   // just a non-zero value
+
+    //  key not found
+    qd_hash_retrieve(hash, i_key, &value);   // does not return error code, but sets value to 0
+    if (value != 0)
+        return "expected hash retrieve to find nothing";
+
+    // remove should return error
+    if (qd_hash_remove(hash, i_key) != QD_ERROR_NOT_FOUND)
+        return "expected hash remove to fail (not found)";
+
+    qd_iterator_free(i_key);
+
+    // cleanup
+
+    for (int i = 0; i < key_count; ++i) {
+        const unsigned char *key = keys[i];
+
+        if (qd_hash_remove_str(hash, key) != QD_ERROR_NONE)
+            return "str key remove failed";
+        qd_hash_handle_free(handles[i]);
+    }
+
+    qd_hash_free(hash);
+    return 0;
+}
+
+
+// test lookup and remove failures using strings
+//
+static char *test_str_bad(void *context)
+{
+
+    qd_hash_handle_t *handles[key_count];

Review comment:
       This does not compile with clang 11, https://travis-ci.org/github/apache/qpid-dispatch/jobs/696018472#L1704
   
   ```/Users/travis/build/apache/qpid-dispatch/tests/hash_test.c:249:31: error: 
         variable length array folded to constant array as an extension
         [-Werror,-Wgnu-folding-constant]
       qd_hash_handle_t *handles[key_count];
                                 ^~~~~~~~~```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] asfgit closed pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] [qpid-dispatch] kgiusti commented on a change in pull request #755: Dispatch 1682: Augment parse tree lookup with a hash table

Posted by GitBox <gi...@apache.org>.
kgiusti commented on a change in pull request #755:
URL: https://github.com/apache/qpid-dispatch/pull/755#discussion_r437458359



##########
File path: include/qpid/dispatch/iterator.h
##########
@@ -329,6 +329,11 @@ int qd_iterator_ncopy(qd_iterator_t *iter, unsigned char* buffer, int n);
  */
 unsigned char *qd_iterator_copy(qd_iterator_t *iter);
 
+/**

Review comment:
       The original is documented as advancing the iterator past the data copied out.  I'm assuming that some codepath relies on that behavior. 
   
   I'll need to audit the existing use cases before we can be sure we can safely make that change.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org