Sfoglia il codice sorgente

Provide a way to configure (at compile time) message and queue sizes.

This patch makes it possible to override the following #defines:
MESSAGE_SIZE_MAX
MESSAGE_QUEUE_MAX
SIZEQUEUE
FLOW_CONTROL_ENTRIES_ENABLE

If MESSAGE_SIZE_MAX is defined as 1024*64 (64K) and
MESSAGE_QUEUE_MAX defined as 512 you can change corosync's
memory footprint from ~48M to ~8M

So if you define MESSAGE_QUEUE_MAX, the queue size will
not be based on the message size any more.

To use this define the defines on the command line:
make CFLAGS="-DMESSAGE_SIZE_MAX=1024*64 -DMESSAGE_QUEUE_MAX=512"



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1656 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld 17 anni fa
parent
commit
31aa88aefb

+ 2 - 0
exec/ipc.c

@@ -99,7 +99,9 @@ LOGSYS_DECLARE_SUBSYS ("IPC", LOG_INFO);
 /*
 /*
  * When there are this many entries left in a queue, turn on flow control
  * When there are this many entries left in a queue, turn on flow control
  */
  */
+#ifndef FLOW_CONTROL_ENTRIES_ENABLE
 #define FLOW_CONTROL_ENTRIES_ENABLE 400
 #define FLOW_CONTROL_ENTRIES_ENABLE 400
+#endif /* FLOW_CONTROL_ENTRIES_ENABLE */
 
 
 /*
 /*
  * When there are this many entries in a queue, turn off flow control
  * When there are this many entries in a queue, turn off flow control

+ 2 - 0
exec/main.h

@@ -48,7 +48,9 @@
  * Size of the queue (entries) for I/O's to the API over socket IPC.
  * Size of the queue (entries) for I/O's to the API over socket IPC.
  */
  */
 
 
+#ifndef SIZEQUEUE
 #define SIZEQUEUE 800
 #define SIZEQUEUE 800
+#endif /* SIZEQUEUE */
 
 
 #define SOCKET_SERVICE_INIT 254
 #define SOCKET_SERVICE_INIT 254
 
 

+ 2 - 2
exec/totemconfig.c

@@ -528,9 +528,9 @@ int totem_config_validate (
 		totem_config->net_mtu = 1500;
 		totem_config->net_mtu = 1500;
 	}
 	}
 
 
-	if ((MESSAGE_SIZE_MAX / totem_config->net_mtu) < totem_config->max_messages) {
+	if ((MESSAGE_QUEUE_MAX) < totem_config->max_messages) {
 		sprintf (local_error_reason, "The max_messages parameter (%d messages) may not be greater then (%d messages).",
 		sprintf (local_error_reason, "The max_messages parameter (%d messages) may not be greater then (%d messages).",
-			totem_config->max_messages, MESSAGE_SIZE_MAX / totem_config->net_mtu);
+			totem_config->max_messages, MESSAGE_QUEUE_MAX);
 		goto parse_error;
 		goto parse_error;
 	}
 	}
 
 

+ 1 - 1
exec/totemsrp.c

@@ -822,7 +822,7 @@ int totemsrp_initialize (
 	 * Must have net_mtu adjusted by totemrrp_initialize first
 	 * Must have net_mtu adjusted by totemrrp_initialize first
 	 */
 	 */
 	queue_init (&instance->new_message_queue,
 	queue_init (&instance->new_message_queue,
-		(MESSAGE_SIZE_MAX / (totem_config->net_mtu - 25) /* for totempg_mcat header */),
+		MESSAGE_QUEUE_MAX,
 		sizeof (struct message_item));
 		sizeof (struct message_item));
 
 
 	return (0);
 	return (0);

+ 8 - 1
include/corosync/engine/coroapi.h

@@ -52,7 +52,14 @@ struct corosync_tpg_group {
 
 
 #define PROCESSOR_COUNT_MAX 384
 #define PROCESSOR_COUNT_MAX 384
 #define INTERFACE_MAX 2
 #define INTERFACE_MAX 2
-#define MESSAGE_SIZE_MAX        1024*1024 /* (1MB) */
+
+#ifndef MESSAGE_SIZE_MAX
+#define MESSAGE_SIZE_MAX	1024*1024 /* (1MB) */
+#endif /* MESSAGE_SIZE_MAX */
+
+#ifndef MESSAGE_QUEUE_MAX
+#define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
+#endif /* MESSAGE_QUEUE_MAX */
 
 
 #define TOTEM_AGREED	0
 #define TOTEM_AGREED	0
 #define TOTEM_SAFE	1
 #define TOTEM_SAFE	1

+ 7 - 0
include/corosync/totem/totem.h

@@ -36,7 +36,14 @@
 #define TOTEM_H_DEFINED
 #define TOTEM_H_DEFINED
 #include "totemip.h"
 #include "totemip.h"
 
 
+#ifndef MESSAGE_SIZE_MAX
 #define MESSAGE_SIZE_MAX	1024*1024 /* (1MB) */
 #define MESSAGE_SIZE_MAX	1024*1024 /* (1MB) */
+#endif /* MESSAGE_SIZE_MAX */
+
+#ifndef MESSAGE_QUEUE_MAX
+#define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
+#endif /* MESSAGE_QUEUE_MAX */
+
 #define PROCESSOR_COUNT_MAX	384
 #define PROCESSOR_COUNT_MAX	384
 #define FRAME_SIZE_MAX		9000
 #define FRAME_SIZE_MAX		9000
 #define TRANSMITS_ALLOWED	16
 #define TRANSMITS_ALLOWED	16