Speed up FDS read

Hi,

I am developing a health wearable and want to store biosignal data into flash and then read at some point. I found that the reading process is relative slow as I tested (about 730 bytes/s). Is there any way to speed up the fds reading process? I have attached my read function bellow. Thank you so much!

ret_code_t fds_read_sub(uint16_t fid, uint16_t key_id, void * p_data ,uint32_t len_in_byte)
{
        /*It is required to zero the token before first use. */
	memset(&ftok, 0x00, sizeof(fds_find_token_t));

        if(fds_record_find(fid, key_id, &record_desc, &ftok)==NRF_SUCCESS)
	{
		/*Open the record and read its contents. */
		ret_code_t rc = fds_record_open(&record_desc, &flash_record);
		if(rc != NRF_SUCCESS)
                {
                        DEBUG_FDS_ERROR_PRINT("Error when fds record opening;\n");
                        return rc;
                }

		/*Copy the pointer from flash into p_data. */
		memcpy_fast(p_data, flash_record.p_data, len_in_byte);

		/*Close the record when done. */
		if (fds_record_close(&record_desc) != NRF_SUCCESS)
		{
			DEBUG_FDS_ERROR_PRINT("Error when fds record close;\n");
                        return FDS_ERR_NO_OPEN_RECORDS;
		}
	}
	else
	{
		return FDS_ERR_NOT_FOUND;
	}
}

Parents
  • Hi Rjfang, 

    I believe the function that takes the most significant time is the fds_record_find() function. It would loop through the whole file system to look for the next record. I think it's the challenge when you have a file system. The abstraction and wear levering benefit makes it take longer to find and access the data. 

    How large is your database ? How many records do you have on average ? You may want to consider grouping larger data into one record, hence lower the number of record and can bring the searching time lower. 

    I would suggest to test the timing by flipping a GPIO before and after a function and check how long it would take to complete the function using a logic analyzer/oscilloscope. 

Reply
  • Hi Rjfang, 

    I believe the function that takes the most significant time is the fds_record_find() function. It would loop through the whole file system to look for the next record. I think it's the challenge when you have a file system. The abstraction and wear levering benefit makes it take longer to find and access the data. 

    How large is your database ? How many records do you have on average ? You may want to consider grouping larger data into one record, hence lower the number of record and can bring the searching time lower. 

    I would suggest to test the timing by flipping a GPIO before and after a function and check how long it would take to complete the function using a logic analyzer/oscilloscope. 

Children
No Data
Related