-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access file as quickly as possible #49
Comments
The LRU cache was added in ev3dev/ev3dev-lang#25. The benchmarks there suggest the cache does help with the peformance. One other thing to try would be to cache Also, see some discussion in ev3dev/ev3dev#324. It could be that ev3dev polling interval is the limiting factor for you, and not the library performance. |
Here are the extend class to use posix functions and increase performance by 40. How to integrate it better ? You can use the functions to open/read/close each time or use the splitted functions to optimize calls in your own. It increases of course a little bit more the performance. ev3dev_extend.h
ev3dev_extend.cpp
|
The performance gains look interesting. All file operations in ev3dev.cpp are implemented in terms of |
That's why I created the extended class, you can see above. |
Did you try to compare the performance of POSIX API with that of I mean, in your code there is a lot of calls to
Not anymore: 2f7c128 |
Sorry I don't understand. I'm using above in the class ev3dev_extend. => The result is that POSIX functions are the fastest, that's why I created this class to contribute and give to the community my conclusions ;) |
The code in #56 is loosely based on your code (thanks for that, by the way!), and replaces So could you please rerun your set of tests with |
You're welcome. Ok, understood now and I saw your code using the LRU_cache in the #56, sorry for the misunderstanding. I can do and plan a new benchmark next week (not available this week-end, and also because my colleague have the robot). |
Hi, Problem with the cache ?
|
I think this may be because I forgot to do |
It doesn't help with read (for the encoders). About the write, it's like just an impulse on the motor, weird... |
Another try: bb8a873 disables io buffering for the opened files. |
No pb ;) It's working well.
For the write, sometimes instead of 300/400us the write tooks 1ms or or or 4ms (1 request on 10)
|
The long exceptional timings (>4ms) seem linked to my log system. |
How does this compare to the posix timings? |
Here is the same test with my extend class and optimisations of opened files, the average is a little bit less (always under 500us) Read 2 encoders
Write 2 motors (second writing is always less...)
|
My next guess is that our LRU cache has some overhead. The files are keyed by paths, so finding correct file handle involves a number of string comparisons. Your extend class stores the file handles directly, which makes it faster. Do you have the results for the current (iostream-based) ev3dev.cpp somewhere? |
I keep in this test exactly the same test with same priority of threads, otherwise timings are biggers more often. Read 2 encoders
write 2 motors
|
Hi,
I'm trying to optimise the access to the file value0 for angle sensors, or IR sensors.
Because my motion system need these data every 5ms.
ifstream is currently used, I already managed some little change to decrease access time, but it's not enough (I opened the file once at the beginning, and during the loop, I just read).
Do you know how to be faster to retrieve the value (int) inside the file ?
Maybe using POSIX like described here
https://stackoverflow.com/questions/17925051/fast-textfile-reading-in-c
What do you think ?
You seem to use a cache, but I don't understand, Are you sure that the cache is really used using this current code in ev3dev.cpp ?
BR,
Cho.
The text was updated successfully, but these errors were encountered: