Re: [filesystem-api] Observable is not appropriate for directory listing; async iterable would be better (#4)

Evangelizer-in-chief here. ;)

It's true that an asynchronous iterator gives the consumer control (back pressure). However it's not clear to me what the motivating use cases are for that control. It is important to spell that out because back pressure support will come at hefty performance cost given the fine granularity of the proposed API.

Let's say you did a deep enumeration and saw 1000 files (not unrealistic). You would get a minimum of 1000 promise allocations. A single map operation would double the number of promise allocations to 2000. Assuming you were calling next() again before the previous Promise resolved you would be growing the job queue as well notifications were queued up.

Comparably an Observable would involve only three allocations: minimally the observer, subscription, and Observable. A map operation would introduce another three allocations + 1 extra allocation for the map closure argument. In other words the allocations would not grow with the number of files being processed. 

Under the circumstances it seems like it's worth enumerating the motivating cases for back pressure here. If there are compelling use cases, an asynchronous iterator might be made more efficient if we made the granularity of the API more coarse. (AsyncIterator<Promise<Array<File>>>)



---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/filesystem-api/issues/4#issuecomment-106978841

Received on Saturday, 30 May 2015 02:51:40 UTC