This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5726: SDK 6.01 performance issue

Part Number: AM5726
Other Parts Discussed in Thread: BEAGLEBOARD-X15

Hi,

In our team, we are migrating from SDK3 (ti-processor-sdk-linux-rt-am57xx-evm-03.03.00.04) to SDK6 (ti-processor-sdk-linux-rt-am57xx-evm-06.01.00.08). While doing the migration, we have observed there is a performance loss with the SDK6. We have decided to take a test on BeagleBoard-X15 with the stock kernel without changing what the TI delivers. I have created simple applications to observe the differences running on BB-X15, please see below:

Example of memory management:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define ONE_KB	1024
#define ONE_MB	ONE_KB*1024
#define MEM_SIZE 8*ONE_MB*sizeof(char)


#define FIRST_MALLOC_TEST
#define SECOND_MALLOC_TEST
#define CALLOC_TEST
#define STACK_TEST

int main (void)
{
	char * heap = NULL;
	clock_t start, end;
	double cpu_time_used;

#ifdef FIRST_MALLOC_TEST
	{/*1. Malloc Test Start*/
		{
      printf("--- Malloc Test ---\n");
			start = clock();
			heap = malloc(MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Allocated with malloc in %fms \n",cpu_time_used);

		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("1. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xAA,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("2. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("3. Set in %fms \n",cpu_time_used);
		}

		{
			FILE *fp;
			start = clock();
			fp = fopen("/dev/null", "a+");
		 	fwrite (heap , sizeof(char), 8*ONE_MB, fp);
			fclose(fp);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Written to the /dev/null in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			free(heap);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("freed in %fms \n",cpu_time_used);
		}
	}/*1. Malloc Test End*/
#endif

#ifdef CALLOC_TEST
	{/*Calloc test Start*/
		{
      printf("--- Calloc Test ---\n");
			start = clock();
			heap = calloc(1,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Allocated with calloc in %fms \n",cpu_time_used);

		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("1. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xAA,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("2. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("3. Set in %fms \n",cpu_time_used);
		}

		{
			FILE *fp;
			start = clock();
			fp = fopen("/dev/null", "a+");
		 	fwrite (heap , sizeof(char), 8*ONE_MB, fp);
			fclose(fp);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Written to the /dev/null in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			free(heap);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("freed in %fms \n",cpu_time_used);
		}
	}/*Calloc test End*/
#endif

#ifdef SECOND_MALLOC_TEST
	{/*2. Malloc Test Start*/
		{
      printf("--- Malloc Test ---\n");
			start = clock();
			heap = malloc(MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Allocated with malloc in %fms \n",cpu_time_used);

		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("1. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xAA,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("2. Set in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(heap,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("3. Set in %fms \n",cpu_time_used);
		}

		{
			FILE *fp;
			start = clock();
			fp = fopen("/dev/null", "a+");
		 	fwrite (heap , sizeof(char), 8*ONE_MB, fp);
			fclose(fp);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("Written to the /dev/null in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			free(heap);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("freed in %fms \n",cpu_time_used);
		}
	}/*2. Malloc Test End*/
#endif
#ifdef STACK_TEST
	{/*Stack Test Start*/
		static char stack[8*ONE_MB];

		{
      printf("--- Stack Test ---\n");
			start = clock();
			memset(stack,0xCC,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("1. Set from stack in %fms \n",cpu_time_used);
		}

		{
			start = clock();
			memset(stack,0xAA,MEM_SIZE);
			end = clock();
			cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC*1000;
			printf("2. Set from stack in %fms \n",cpu_time_used);
		}
	}/*Stack Test End*/
#endif

	return 0;
}

The results with SDK3:

The results with SDK6:

I appreciate it if we could solve this performance issue.

Kind regards,

Mustafa

  • Hello and thanks for your post.

    Could you please share more details on what you are seeing that caused you to believe there is a performance difference between the two?

    Also, have you tried your test with multiple iterations, say 100, to make sure the differences are just caused by random events in the system?

    Thank you.

  • Hi Ron,

    We were previously using SDK3 in our application. The performance metrics are well measured within the tests. And we would like to migrate to the SDK6. After migration. We have run the same tests and the results are much much worse. We have investigated the issue for a long time and we have achieved to create a test case for you. And tested on BB-X15 seperately. You can see the test code below. I am pretty sure the performance decrease is not caused by random events. There is also a performance decrease in the system calls. We see the main reason of the performance decrease is the kernel. Definitely Linux kernel.

    Kind regards,

    Mustafa

  • Hi,

    I have found another performance problem regarding SDK6. (I am still using BeagleBoard-X15.) Assume that we have an application or script having the same effect:

    #include <stdio.h>
    
    int main()
    {
      for (int i = 0; i < 60000000; ++i) {
        usleep(1);
      }
    
      return 0;
    }
    

    Unfortunately, this application has a different performance between SDK3 and SDK6. 

    SDK3:

    SDK6:


    The application utilizes CPU for kernel threads in a different way in different SDKs. If we have a separate application besides this application, there will be a performance decrease.

    I appreciate it if you could help me regarding the issue.

    Kind regards,

    Mustafa