xiaoxiang781216 commented on issue #2834:
URL: 
https://github.com/apache/incubator-nuttx/issues/2834#issuecomment-778239483


   > It would be great to support this as it is very common for me to start 
building app my project logic when it eventually fails to due opening to many 
FDs. It is the kind of setting that requires guesswork, which is not ideal.
   > 
   > Do you think it could affect performance? I imagine it would require 
traversing a list for every file operation. Or would you reallocate an array?
   
   Yes, fd->file conversion become to O(n) operation if we switch to list, but 
the reallocation array isn't perfect too, because:
   
   1. All file pointers will be invalid after reallocation, we has to hold the 
lock in the entire fs call.
   2. It's very hard to find the big continuous free memory to hold the fd array
   
   so we propose a two layer array structure(like STL deque):
   
![image](https://user-images.githubusercontent.com/18066964/107781849-3a906780-6cfd-11eb-9406-a213a44998a3.png)
   
   We can get both benefit from list and array:
   
   1. Convert fd to file in O(1)
   2. Allocated file struct never become invalid
   3. Don't require the bigger and bigger continuous free memory
   4. Avoid the housekeeping overhead of list(each file ~12 bytes)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to