You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2019/11/26 14:15:19 UTC

[qpid-proton] branch master updated (b53246c -> 6be92fc)

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git.


    from b53246c  PROTON-2146: reduce memory per connection for lightly loaded connections
     new 98c2347  PROTON-2140: Better packing of some structs - Small but worthwhile gain - Store enums as uint8_t as they don't use more bits than this - Rearrange some structs to eliminate holes
     new 6be92fc  PROTON-2140: Remove unused error object from endpoints - Another small but worthwhile gain - endpoint is used extensively.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 c/include/proton/cid.h        |  2 --
 c/include/proton/connection.h |  3 +++
 c/include/proton/link.h       |  3 +++
 c/include/proton/session.h    |  3 +++
 c/src/core/engine-internal.h  | 34 ++++++++++++++++------------------
 c/src/core/engine.c           | 31 +++++++------------------------
 c/src/core/error.c            |  8 ++++++++
 c/src/core/transport.c        |  2 +-
 8 files changed, 41 insertions(+), 45 deletions(-)


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


[qpid-proton] 01/02: PROTON-2140: Better packing of some structs - Small but worthwhile gain - Store enums as uint8_t as they don't use more bits than this - Rearrange some structs to eliminate holes

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 98c23470142237b81071cd4ad523db7641f6ba16
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon Nov 25 19:35:27 2019 -0500

    PROTON-2140: Better packing of some structs
    - Small but worthwhile gain
    - Store enums as uint8_t as they don't use more bits than this
    - Rearrange some structs to eliminate holes
---
 c/include/proton/cid.h       |  2 --
 c/src/core/engine-internal.h | 35 +++++++++++++++++------------------
 c/src/core/engine.c          | 14 +++++++-------
 c/src/core/transport.c       |  2 +-
 4 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/c/include/proton/cid.h b/c/include/proton/cid.h
index e0766a0..ca08356 100644
--- a/c/include/proton/cid.h
+++ b/c/include/proton/cid.h
@@ -40,8 +40,6 @@ typedef enum {
   CID_pn_collector,
   CID_pn_event,
 
-  CID_pn_encoder,
-  CID_pn_decoder,
   CID_pn_data,
 
   CID_pn_connection,
diff --git a/c/src/core/engine-internal.h b/c/src/core/engine-internal.h
index a115b1a..b8906eb 100644
--- a/c/src/core/engine-internal.h
+++ b/c/src/core/engine-internal.h
@@ -42,16 +42,16 @@ struct pn_condition_t {
 };
 
 struct pn_endpoint_t {
-  pn_endpoint_type_t type;
-  pn_state_t state;
-  pn_error_t *error;
   pn_condition_t condition;
   pn_condition_t remote_condition;
+  pn_error_t *error;
   pn_endpoint_t *endpoint_next;
   pn_endpoint_t *endpoint_prev;
   pn_endpoint_t *transport_next;
   pn_endpoint_t *transport_prev;
   int refcount; // when this hits zero we generate a final event
+  uint8_t state;
+  uint8_t type;
   bool modified;
   bool freed;
   bool referenced;
@@ -78,26 +78,25 @@ typedef struct {
 } pn_link_state_t;
 
 typedef struct {
-  // XXX: stop using negative numbers
-  uint16_t local_channel;
-  uint16_t remote_channel;
-  bool incoming_init;
   pn_delivery_map_t incoming;
   pn_delivery_map_t outgoing;
+  pn_hash_t *local_handles;
+  pn_hash_t *remote_handles;
+  uint64_t disp_code;
   pn_sequence_t incoming_transfer_count;
   pn_sequence_t incoming_window;
   pn_sequence_t remote_incoming_window;
   pn_sequence_t outgoing_transfer_count;
   pn_sequence_t outgoing_window;
-  pn_hash_t *local_handles;
-  pn_hash_t *remote_handles;
-
-  uint64_t disp_code;
-  bool disp_settled;
-  bool disp_type;
   pn_sequence_t disp_first;
   pn_sequence_t disp_last;
+  // XXX: stop using negative numbers
+  uint16_t local_channel;
+  uint16_t remote_channel;
+  bool incoming_init;
   bool disp;
+  bool disp_settled;
+  bool disp_type;
 } pn_session_state_t;
 
 typedef struct pn_io_layer_t {
@@ -253,6 +252,7 @@ struct pn_connection_t {
 
 struct pn_session_t {
   pn_endpoint_t endpoint;
+  pn_session_state_t state;
   pn_connection_t *connection;  // reference counted
   pn_list_t *links;
   pn_list_t *freed;
@@ -263,7 +263,6 @@ struct pn_session_t {
   pn_sequence_t incoming_deliveries;
   pn_sequence_t outgoing_deliveries;
   pn_sequence_t outgoing_window;
-  pn_session_state_t state;
 };
 
 struct pn_terminus_t {
@@ -272,11 +271,11 @@ struct pn_terminus_t {
   pn_data_t *capabilities;
   pn_data_t *outcomes;
   pn_data_t *filter;
-  pn_durability_t durability;
-  pn_expiry_policy_t expiry_policy;
   pn_seconds_t timeout;
-  pn_terminus_type_t type;
-  pn_distribution_mode_t distribution_mode;
+  uint8_t durability;
+  uint8_t expiry_policy;
+  uint8_t type;
+  uint8_t distribution_mode;
   bool has_expiry_policy;
   bool dynamic;
 };
diff --git a/c/src/core/engine.c b/c/src/core/engine.c
index 3c3c24c..6767b28 100644
--- a/c/src/core/engine.c
+++ b/c/src/core/engine.c
@@ -75,7 +75,7 @@ static void pn_endpoint_open(pn_endpoint_t *endpoint)
     PN_SET_LOCAL(endpoint->state, PN_LOCAL_ACTIVE);
     pn_connection_t *conn = pni_ep_get_connection(endpoint);
     pn_collector_put(conn->collector, PN_OBJECT, endpoint,
-                     endpoint_event(endpoint->type, true));
+                     endpoint_event((pn_endpoint_type_t) endpoint->type, true));
     pn_modified(conn, endpoint, true);
   }
 }
@@ -86,7 +86,7 @@ static void pn_endpoint_close(pn_endpoint_t *endpoint)
     PN_SET_LOCAL(endpoint->state, PN_LOCAL_CLOSED);
     pn_connection_t *conn = pni_ep_get_connection(endpoint);
     pn_collector_put(conn->collector, PN_OBJECT, endpoint,
-                     endpoint_event(endpoint->type, false));
+                     endpoint_event((pn_endpoint_type_t) endpoint->type, false));
     pn_modified(conn, endpoint, true);
   }
 }
@@ -445,7 +445,7 @@ void pn_ep_decref(pn_endpoint_t *endpoint)
   endpoint->refcount--;
   if (endpoint->refcount == 0) {
     pn_connection_t *conn = pni_ep_get_connection(endpoint);
-    pn_collector_put(conn->collector, PN_OBJECT, endpoint, pn_final_type(endpoint->type));
+    pn_collector_put(conn->collector, PN_OBJECT, endpoint, pn_final_type((pn_endpoint_type_t) endpoint->type));
   }
 }
 
@@ -1236,7 +1236,7 @@ int pn_terminus_set_type(pn_terminus_t *terminus, pn_terminus_type_t type)
 
 pn_terminus_type_t pn_terminus_get_type(pn_terminus_t *terminus)
 {
-  return terminus ? terminus->type : (pn_terminus_type_t) 0;
+  return (pn_terminus_type_t) (terminus ? terminus->type : 0);
 }
 
 const char *pn_terminus_get_address(pn_terminus_t *terminus)
@@ -1253,7 +1253,7 @@ int pn_terminus_set_address(pn_terminus_t *terminus, const char *address)
 
 pn_durability_t pn_terminus_get_durability(pn_terminus_t *terminus)
 {
-  return terminus ? terminus->durability : (pn_durability_t) 0;
+  return (pn_durability_t) (terminus ? terminus->durability : 0);
 }
 
 int pn_terminus_set_durability(pn_terminus_t *terminus, pn_durability_t durability)
@@ -1265,7 +1265,7 @@ int pn_terminus_set_durability(pn_terminus_t *terminus, pn_durability_t durabili
 
 pn_expiry_policy_t pn_terminus_get_expiry_policy(pn_terminus_t *terminus)
 {
-  return terminus ? terminus->expiry_policy : (pn_expiry_policy_t) 0;
+  return (pn_expiry_policy_t) (terminus ? terminus->expiry_policy : 0);
 }
 
 bool pn_terminus_has_expiry_policy(const pn_terminus_t *terminus)
@@ -1327,7 +1327,7 @@ pn_data_t *pn_terminus_filter(pn_terminus_t *terminus)
 
 pn_distribution_mode_t pn_terminus_get_distribution_mode(const pn_terminus_t *terminus)
 {
-  return terminus ? terminus->distribution_mode : PN_DIST_MODE_UNSPECIFIED;
+  return terminus ? (pn_distribution_mode_t) terminus->distribution_mode : PN_DIST_MODE_UNSPECIFIED;
 }
 
 int pn_terminus_set_distribution_mode(pn_terminus_t *terminus, pn_distribution_mode_t m)
diff --git a/c/src/core/transport.c b/c/src/core/transport.c
index 0a930ae..ee00ad2 100644
--- a/c/src/core/transport.c
+++ b/c/src/core/transport.c
@@ -2041,7 +2041,7 @@ static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endp
         !(endpoint->state & PN_LOCAL_UNINIT) && state->local_handle == (uint32_t) -1)
     {
       pni_map_local_handle(link);
-      const pn_distribution_mode_t dist_mode = link->source.distribution_mode;
+      const pn_distribution_mode_t dist_mode = (pn_distribution_mode_t) link->source.distribution_mode;
       if (link->target.type == PN_COORDINATOR) {
         int err = pn_post_frame(transport, AMQP_FRAME_TYPE, ssn_state->local_channel,
                                 "DL[SIoBB?DL[SIsIoC?sCnCC]DL[C]nnI]", ATTACH,


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


[qpid-proton] 02/02: PROTON-2140: Remove unused error object from endpoints - Another small but worthwhile gain - endpoint is used extensively.

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 6be92fc56ea68187b9e36946790fe977db57809a
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Nov 26 09:13:13 2019 -0500

    PROTON-2140: Remove unused error object from endpoints
    - Another small but worthwhile gain - endpoint is used extensively.
---
 c/include/proton/connection.h |  3 +++
 c/include/proton/link.h       |  3 +++
 c/include/proton/session.h    |  3 +++
 c/src/core/engine-internal.h  |  1 -
 c/src/core/engine.c           | 17 -----------------
 c/src/core/error.c            |  8 ++++++++
 6 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/c/include/proton/connection.h b/c/include/proton/connection.h
index ae8907b..9814828 100644
--- a/c/include/proton/connection.h
+++ b/c/include/proton/connection.h
@@ -130,6 +130,9 @@ PN_EXTERN void pn_connection_release(pn_connection_t *connection);
  * The pointer returned by this operation is valid until the
  * connection object is freed.
  *
+ * Deprecation notice: note that this will always return an empty
+ * error object
+ *
  * @param[in] connection the connection object
  * @return the connection's error object
  */
diff --git a/c/include/proton/link.h b/c/include/proton/link.h
index 0d45df9..c7e3f5b 100644
--- a/c/include/proton/link.h
+++ b/c/include/proton/link.h
@@ -176,6 +176,9 @@ PN_EXTERN pn_error_t *pn_link_error(pn_link_t *link);
  * The pointer returned by this operation is valid until the link
  * object is freed.
  *
+ * Deprecation notice: note that this will always return an empty
+ * error object
+ *
  * @param[in] link the link object
  * @return the link's local condition object
  */
diff --git a/c/include/proton/session.h b/c/include/proton/session.h
index d9118ac..8cbdb5b 100644
--- a/c/include/proton/session.h
+++ b/c/include/proton/session.h
@@ -118,6 +118,9 @@ PN_EXTERN pn_state_t pn_session_state(pn_session_t *session);
  * The pointer returned by this operation is valid until the
  * session object is freed.
  *
+ * Deprecation notice: note that this will always return an empty
+ * error object
+ *
  * @param[in] session the session object
  * @return the session's error object
  */
diff --git a/c/src/core/engine-internal.h b/c/src/core/engine-internal.h
index b8906eb..0df2d2f 100644
--- a/c/src/core/engine-internal.h
+++ b/c/src/core/engine-internal.h
@@ -44,7 +44,6 @@ struct pn_condition_t {
 struct pn_endpoint_t {
   pn_condition_t condition;
   pn_condition_t remote_condition;
-  pn_error_t *error;
   pn_endpoint_t *endpoint_next;
   pn_endpoint_t *endpoint_prev;
   pn_endpoint_t *transport_next;
diff --git a/c/src/core/engine.c b/c/src/core/engine.c
index 6767b28..f2e3072 100644
--- a/c/src/core/engine.c
+++ b/c/src/core/engine.c
@@ -389,7 +389,6 @@ void pn_endpoint_init(pn_endpoint_t *endpoint, int type, pn_connection_t *conn)
   endpoint->type = (pn_endpoint_type_t) type;
   endpoint->referenced = true;
   endpoint->state = PN_LOCAL_UNINIT | PN_REMOTE_UNINIT;
-  endpoint->error = pn_error();
   pn_condition_init(&endpoint->condition);
   pn_condition_init(&endpoint->remote_condition);
   endpoint->endpoint_next = NULL;
@@ -451,7 +450,6 @@ void pn_ep_decref(pn_endpoint_t *endpoint)
 
 static void pni_endpoint_tini(pn_endpoint_t *endpoint)
 {
-  pn_error_free(endpoint->error);
   pn_condition_tini(&endpoint->remote_condition);
   pn_condition_tini(&endpoint->condition);
 }
@@ -569,11 +567,6 @@ pn_state_t pn_connection_state(pn_connection_t *connection)
   return connection ? connection->endpoint.state : 0;
 }
 
-pn_error_t *pn_connection_error(pn_connection_t *connection)
-{
-  return connection ? connection->endpoint.error : NULL;
-}
-
 const char *pn_connection_get_container(pn_connection_t *connection)
 {
   assert(connection);
@@ -1075,11 +1068,6 @@ pn_state_t pn_session_state(pn_session_t *session)
   return session->endpoint.state;
 }
 
-pn_error_t *pn_session_error(pn_session_t *session)
-{
-  return session->endpoint.error;
-}
-
 static void pni_terminus_init(pn_terminus_t *terminus, pn_terminus_type_t type)
 {
   terminus->type = type;
@@ -1378,11 +1366,6 @@ pn_state_t pn_link_state(pn_link_t *link)
   return link->endpoint.state;
 }
 
-pn_error_t *pn_link_error(pn_link_t *link)
-{
-  return link->endpoint.error;
-}
-
 const char *pn_link_name(pn_link_t *link)
 {
   assert(link);
diff --git a/c/src/core/error.c b/c/src/core/error.c
index 070144a..f64c763 100644
--- a/c/src/core/error.c
+++ b/c/src/core/error.c
@@ -136,3 +136,11 @@ const char *pn_code(int code)
   default: return "<unknown>";
   }
 }
+
+// Deprecated ABI compatibility stubs
+// Make sure that no one is actually trying to change this.
+static const pn_error_t nullerror = {NULL, 0};
+
+pn_error_t *pn_connection_error(pn_connection_t *c) {return (pn_error_t*) &nullerror;}
+pn_error_t *pn_session_error(pn_session_t *c) {return (pn_error_t*) &nullerror;}
+pn_error_t *pn_link_error(pn_link_t *c) {return (pn_error_t*) &nullerror;}


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