Skip to content
Snippets Groups Projects
Commit 0c4f341b authored by Moe Jette's avatar Moe Jette
Browse files

Make the sbcast buffer large right from the start to avoid realloc calls.

parent 39ef52be
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@
*/
strong_alias(create_buf, slurm_create_buf);
strong_alias(free_buf, slurm_free_buf);
strong_alias(grow_buf, slurm_grow_buf);
strong_alias(init_buf, slurm_init_buf);
strong_alias(xfer_buf_data, slurm_xfer_buf_data);
strong_alias(pack_time, slurm_pack_time);
......@@ -96,6 +97,13 @@ void free_buf(Buf my_buf)
xfree(my_buf);
}
/* Grow a buffer by the specified amount */
void grow_buf (Buf buffer, int size)
{
buffer->size += size;
xrealloc(buffer->head, buffer->size);
}
/* init_buf - create an empty buffer of the given size */
Buf init_buf(int size)
{
......
......@@ -66,6 +66,7 @@ typedef struct slurm_buf * Buf;
Buf create_buf (char *data, int size);
void free_buf(Buf my_buf);
Buf init_buf(int size);
void grow_buf (Buf my_buf, int size);
void *xfer_buf_data(Buf my_buf);
void pack_time(time_t val, Buf buffer);
......
......@@ -3581,9 +3581,13 @@ _unpack_checkpoint_resp_msg(checkpoint_resp_msg_t **msg_ptr, Buf buffer)
static void _pack_file_bcast(file_bcast_msg_t * msg , Buf buffer )
{
int i;
int buf_size = 1024, i;
xassert ( msg != NULL );
for (i=0; i<FILE_BLOCKS; i++)
buf_size += msg->block_len[i];
grow_buf(buffer, buf_size);
pack16 ( msg->block_no, buffer );
pack16 ( msg->last_block, buffer );
pack16 ( msg->force, buffer );
......
......@@ -187,6 +187,7 @@
/* pack.[ch] functions */
#define create_buf slurm_create_buf
#define free_buf slurm_free_buf
#define grow_buf slurm_grow_buf
#define init_buf slurm_init_buf
#define xfer_buf_data slurm_xfer_buf_data
#define pack_time slurm_pack_time
......
......@@ -50,7 +50,7 @@
#include "src/sbcast/sbcast.h"
#define MAX_RETRIES 10
#define MAX_THREADS 3 /* These can be huge messages, so
#define MAX_THREADS 4 /* These can be huge messages, so
* only run MAX_THREADS at one time */
typedef struct thd {
pthread_t thread; /* thread ID */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment