Iovectorized version of previous patch. Alloca + memcpy is still there,
but only for lib_event_data structure, not for led_body.
Regards,
Honza
Steven Dake wrote:
> This patch looks pretty good but it copies via alloca+memcpy the entire
> event data buffer which doesn't change. Is it possible to send it as an
> iovector to avoid the extra copy?
> If not, go ahead and merge, but the memcpy of event buffer data is somewhat
> detrimental to performance.
>
> Regards
> -steve
>
> On Thu, Apr 30, 2009 at 4:08 AM, Jan Friesse <[email protected]> wrote:
>
>> Sorry, bad patch included in last mail.
>>
>>
>> Jan Friesse wrote:
>>
>>> This patch fixes evt.c, so now no warnings are there.
>>>
>>> Regards,
>>> Honza
>>>
>>>
>> _______________________________________________
>> Openais mailing list
>> [email protected]
>> https://lists.linux-foundation.org/mailman/listinfo/openais
>>
>
Index: services/evt.c
===================================================================
--- services/evt.c (revision 1878)
+++ services/evt.c (working copy)
@@ -109,7 +109,7 @@
static void lib_evt_unlink_channel(void *conn, const void *message);
static void lib_evt_event_subscribe(void *conn, const void *message);
static void lib_evt_event_unsubscribe(void *conn, const void *message);
-static void lib_evt_event_publish(void *conn, void *message);
+static void lib_evt_event_publish(void *conn, const void *message);
static void lib_evt_event_clear_retentiontime(void *conn, const void *message);
static void lib_evt_event_data_get(void *conn, const void *message);
@@ -182,8 +182,8 @@
};
-static void evt_remote_evt(void *msg, unsigned int nodeid);
-static void evt_remote_recovery_evt(void *msg, unsigned int nodeid);
+static void evt_remote_evt(const void *msg, unsigned int nodeid);
+static void evt_remote_recovery_evt(const void *msg, unsigned int nodeid);
static void evt_remote_chan_op(const void *msg, unsigned int nodeid);
static struct corosync_exec_handler evt_exec_engine[] = {
@@ -2691,16 +2691,17 @@
/*
* saEvtEventPublish Handler
*/
-static void lib_evt_event_publish(void *conn, void *message)
+static void lib_evt_event_publish(void *conn, const void *message)
{
- struct lib_event_data *req = message;
+ struct lib_event_data *req;
+ const struct lib_event_data *req_ro = message;
struct res_evt_event_publish res;
struct event_svr_channel_open *eco;
struct event_svr_channel_instance *eci;
mar_evteventid_t event_id = 0;
uint64_t msg_id = 0;
SaAisErrorT error = SA_AIS_OK;
- struct iovec pub_iovec;
+ struct iovec pub_iovec[2];
void *ptr;
int result;
unsigned int ret;
@@ -2713,6 +2714,12 @@
/*
+ * Allocate new req and copy there message
+ */
+ req = alloca (sizeof (*req));
+ memcpy (req, message, sizeof (*req));
+
+ /*
* look up and validate open channel info
*/
ret = hdb_handle_get(&esip->esi_hdb,
@@ -2741,9 +2748,11 @@
* The multicasted event will be picked up and delivered
* locally by the local network event receiver.
*/
- pub_iovec.iov_base = (char *)req;
- pub_iovec.iov_len = req->led_head.size;
- result = api->totem_mcast (&pub_iovec, 1, TOTEM_AGREED);
+ pub_iovec[0].iov_base = (char *)req;
+ pub_iovec[0].iov_len = sizeof (*req);
+ pub_iovec[1].iov_base = (char *)&req_ro->led_body;
+ pub_iovec[1].iov_len = req->led_user_data_offset + req->led_user_data_size;
+ result = api->totem_mcast (pub_iovec, 2, TOTEM_AGREED);
if (result != 0) {
error = SA_AIS_ERR_LIBRARY;
}
@@ -2903,7 +2912,7 @@
{
log_printf(RECOVERY_DEBUG, "Evt conf change %d\n",
configuration_type);
- log_printf(RECOVERY_DEBUG, "m %"PRIu64", j %"PRIu64" l %"PRIu64,
+ log_printf(RECOVERY_DEBUG, "m %u, j %u l %u",
member_list_entries,
joined_list_entries,
left_list_entries);
@@ -3207,7 +3216,7 @@
/*
* Receive the network event message and distribute it to local subscribers
*/
-static void evt_remote_evt(void *msg, unsigned int nodeid)
+static void evt_remote_evt(const void *msg, unsigned int nodeid)
{
/*
* - retain events that have a retention time
@@ -3216,10 +3225,11 @@
* - Apply filters
* - Deliver events that pass the filter test
*/
- struct lib_event_data *evtpkt = msg;
+ const struct lib_event_data *evtpkt = msg;
struct event_svr_channel_instance *eci;
struct event_data *evt;
SaClmClusterNodeT *cn;
+ mar_time_t evtpkt_recieve_time;
log_printf(LOGSYS_LEVEL_DEBUG, "Remote event data received from nodeid %s\n",
api->totem_ifaces_print (nodeid));
@@ -3241,9 +3251,7 @@
log_printf(LOGSYS_LEVEL_DEBUG, "Cluster node ID %s name %s\n",
api->totem_ifaces_print (cn->nodeId), cn->nodeName.value);
- evtpkt->led_publisher_node_id = nodeid;
- evtpkt->led_nodeid = nodeid;
- evtpkt->led_receive_time = clust_time_now();
+ evtpkt_recieve_time = clust_time_now();
if (evtpkt->led_chan_unlink_id != EVT_CHAN_ACTIVE) {
log_printf(CHAN_UNLINK_DEBUG,
@@ -3288,6 +3296,10 @@
return;
}
+ evt->ed_event.led_publisher_node_id = nodeid;
+ evt->ed_event.led_nodeid = nodeid;
+ evt->ed_event.led_receive_time = evtpkt_recieve_time;
+
if (evt->ed_event.led_retention_time) {
retain_event(evt);
}
@@ -3312,7 +3324,7 @@
/*
* Receive a recovery network event message and save it in the retained list
*/
-static void evt_remote_recovery_evt(void *msg, unsigned int nodeid)
+static void evt_remote_recovery_evt(const void *msg, unsigned int nodeid)
{
/*
* - calculate remaining retention time
@@ -3321,12 +3333,13 @@
* - Apply filters
* - Deliver events that pass the filter test
*/
- struct lib_event_data *evtpkt = msg;
+ const struct lib_event_data *evtpkt = msg;
struct event_svr_channel_instance *eci;
struct event_data *evt;
struct member_node_data *md;
int num_delivered;
mar_time_t now;
+ mar_time_t evtpkt_retention_time;
now = clust_time_now();
@@ -3351,7 +3364,7 @@
/*
* Calculate remaining retention time
*/
- evtpkt->led_retention_time = calc_retention_time(
+ evtpkt_retention_time = calc_retention_time(
evtpkt->led_retention_time,
evtpkt->led_receive_time,
now);
@@ -3410,6 +3423,8 @@
return;
}
+ evt->ed_event.led_retention_time = evtpkt_retention_time;
+
retain_event(evt);
num_delivered = try_deliver_event(evt, eci);
log_printf(RECOVERY_EVENT_DEBUG, "Delivered to %d subscribers\n",
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais