Hi ev3dev, first of all, thanks for putting together an awesome set of tools. This is exactly what I was hoping to find!
This PR implements a small cache of file handles for the C++ language bindings. This is discussed in issue #12. This is important to me because I'm trying to build some pretty stiff controllers. In this situation, the lower the latency (and higher the sample rate) the better.
I think that the cache should hopefully alleviate the concerns mentioned in discussion on #12 regarding caching file handles consuming too many OS resources. The global LRU cache guarantees that there will only be < FILE_CACHE_SIZE file handles open at once. I think that this PR should basically make the cases that care about performance faster (reading/writing a few attributes very frequently in a tight loop) while keeping similar performance/resource consumption for other programs.
I benchmarked a program that reads the same attribute repeatedly in a tight loop:
Hi ev3dev, first of all, thanks for putting together an awesome set of tools. This is exactly what I was hoping to find!
This PR implements a small cache of file handles for the C++ language bindings. This is discussed in issue #12. This is important to me because I'm trying to build some pretty stiff controllers. In this situation, the lower the latency (and higher the sample rate) the better.
I think that the cache should hopefully alleviate the concerns mentioned in discussion on #12 regarding caching file handles consuming too many OS resources. The global LRU cache guarantees that there will only be < FILE_CACHE_SIZE file handles open at once. I think that this PR should basically make the cases that care about performance faster (reading/writing a few attributes very frequently in a tight loop) while keeping similar performance/resource consumption for other programs.
I benchmarked a program that reads the same attribute repeatedly in a tight loop:
Uncached:
Cached: