Recent

Author Topic: Fast String Buffer in Threaded Application  (Read 1629 times)

kupferstecher

  • Sr. Member
  • ****
  • Posts: 406
Fast String Buffer in Threaded Application
« on: September 19, 2016, 10:33:38 am »
Hello all,

in my application I have string data coming in on COM-ports. Each port is running on its own thread and data has to be passed to the main thread for processing. Passing should be done through a buffer, which is read by the main thread each half second.
My question now is how to implement a performant buffer for strings.

The easy way would be using Ansistrings in an array. But Ansistrings are allocated dynamically so I fear latencies especially if there is a high number of quite short character strings coming in through the port.

To increase speed I considered using ShortStrings, which are statically allocated and thus won't need time for memory management. The problem here is that as they are static the length is fixed, thus a lot of unused memory space is created. This again I think might lead to cache issues resulting in lower performance. Especially as there is not only one buffer, but might be any number depending on the user settings. Each buffer has to be large enough to cover the incoming stream of 0.5 seconds through one port.

How does a 'good' buffer design look like in this szenario?

Thanks!

 

TinyPortal © 2005-2018