3

I’m working on porting our text to speech code to work on QNX (6.6). One challenge is to keep RAM consumption as low as possible, as our high quality voices need access to around 200 Mbyte of data (stored in a single file).

We hoped that we could memory map this 200 Mbyte of data but it looks like mmap() on QNX has a different behaviour than on other OS’s. What we observe is that when a (4Kbyte ?) page is memory mapped, it never gets released before the file is unmapped. Since the access to this 200 Mbyte data block is fairly random (depends on the input text), we end up with the complete 200 Mbyte of data within a few seconds of generated speech.

Could this behaviour be confirmed, and if so, do you know if are there other ways (maybe unique to QNX) where old pages are released back to the OS (we have to play nicely with other processes that are running like media player, navigation, GUI, etc.)?

A second observation is that memory mapping a big file takes several seconds. This is unexpected as well since I thought one of the advantages/purpose of memory mapping is skipping the long load times of data into RAM. We use this line of code to mmap() the data file:

pFileData = mmap(0, cFileData, PROT_READ, MAP_SHARED, hFile, 0);

I think PROT_READ and MAP_SHARED are not so special as to cause long mapping times (on Linux and iOS, mmap() returns immediately).

Any insights on this memory mapping behaviour on QNX would be greatly appreciated.

Koen
  • 31
  • 1
  • Maybe you already have an answer but wanted to share some info on second observation. QNX initialize the memory after doing mmap(). If you mention flag MAP_NOINIT along with MAP_SHARED, that will tell the OS that the zero init is not required and that might save some time. Not sure about the first observation though. I did not find anything about page locking for mmap() memory. – Shaibal Mar 09 '17 at 06:56
  • Thanks for the feedback. In the end (we're nearing completion now), we used various ways to compress the data to reduce it with more than 50%. And we found that some parts of the data needed only to be accessed a few times/second. So we kept those data chunks on the file system and read the required data with a simple fseek/fread combination. – Koen Mar 10 '17 at 09:25

0 Answers0