Переглянути джерело

Retry checkpoint writes on threaded writes if SA_ERR_TRY_AGAIn
received.

(Logical change 1.55)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@184 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 21 роки тому
батько
коміт
bb75c650fd
1 змінених файлів з 15 додано та 5 видалено
  1. 15 5
      test/ckptbenchth.c

+ 15 - 5
test/ckptbenchth.c

@@ -149,6 +149,7 @@ struct threaddata {
 	SaCkptCheckpointHandleT checkpointHandle;
 	int write_count;
 	int write_size;
+	int thread;
 };
 
 void *benchmark_thread (void *arg) 
@@ -172,10 +173,17 @@ void *benchmark_thread (void *arg)
 		/*
 		 * Test checkpoint write
 		 */
+		do {
 		error = saCkptCheckpointWrite (&checkpointHandle,
 			WriteVectorElements,
 			1,
 			&erroroneousVectorIndex);
+		
+//			if (error == SA_ERR_TRY_AGAIN) {
+//				usleep (rand() % 500);
+//			}
+		} while (error == SA_ERR_TRY_AGAIN);
+printf ("done writing for thread %d\n", td->thread);
 		if (error != SA_OK) {
 			printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
 			exit (1);
@@ -201,6 +209,7 @@ void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, in
 		td[i].checkpointHandle = checkpointHandles[i];
 		td[i].write_count = write_count;
 		td[i].write_size = write_size;
+		td[i].thread = i;
 
 		res = pthread_create (&threadt[i], NULL, benchmark_thread, (void *)&td[i]);
 	}
@@ -224,17 +233,18 @@ void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, in
 
 SaNameT checkpointName = { 12, "abra\0" };
 
+#define CHECKPOINT_THREADS 500
 int main (void) {
-	SaCkptCheckpointHandleT checkpointHandles[50];
+	SaCkptCheckpointHandleT checkpointHandles[500];
 	SaErrorT error;
 	int size;
 	int count;
 	int i, j;
 	
 	/*
-	 * Create 50 checkpoints
+	 * Create CHECPOINT_THREADS checkpoints
 	 */
-	for (i  = 0; i < 50; i++) {
+	for (i  = 0; i < CHECKPOINT_THREADS; i++) {
 		sprintf (checkpointName.value, "checkpoint%d \n", i);
 		error = saCkptCheckpointOpen (&checkpointName,
 			&checkpointCreationAttributes,
@@ -251,9 +261,9 @@ int main (void) {
 			strlen ("Initial Data #0") + 1);
 	}
 
-	for (i = 1; i < 50; i++) {	/* i threads */
+	for (i = CHECKPOINT_THREADS-50; i < CHECKPOINT_THREADS; i++) {	/* i threads */
 		count = 3000; /* initial count */
-		size = 1000; /* initial size */
+		size = 100000; /* initial size */
 		printf ("THREADS %d\n", i);
 		for (j = 0; j < 5; j++) { /* number of runs with i threads */
 			threaded_bench (checkpointHandles, i, count, size);