It blocks CPU unnecessarily and incurs additional GC. It's slower than it 
needs to be. That's a problem for any app and it's not in the spirit of 
Node to be so indirect.

Also, it's certainly possible for a server with a few GB of RAM to need to 
async load a huge file into RAM for permanent use there. If it can't 
buffer, if it's that kind of job, then readFile would be the thing to use, 
but it's going to waste a second or two just copying the data around, and 
then there's the problem with the buffer limit.

On Wednesday, May 16, 2012 5:32:14 PM UTC+2, Tim Caswell wrote:
>
> The original fs.readFile I wrote worked somewhat like this.  I don't know 
> the reasons it was rewritten to use streams instead. I had always assumed 
> it was to save code and be more reliable.
>
> Regarding performance, can you measure the difference, has it caused 
> problems is a real app?
>
> And I wouldn't worry about the max size.  You probably shouldn't be using 
> a buffering readFile for files that big.
>
> On Wed, May 16, 2012 at 10:23 AM, Joran Greef <[email protected]> wrote:
>
>> Granted, max buffer size on Mac is about (42949672 * 25) bytes and this 
>> doesn't deal with files bigger than that (about a GB), but then I think 
>> neither does fs.readFile (perhaps this needs to be fixed).
>
>
>
On Wednesday, May 16, 2012 5:32:14 PM UTC+2, Tim Caswell wrote:
>
> The original fs.readFile I wrote worked somewhat like this.  I don't know 
> the reasons it was rewritten to use streams instead. I had always assumed 
> it was to save code and be more reliable.
>
> Regarding performance, can you measure the difference, has it caused 
> problems is a real app?
>
> And I wouldn't worry about the max size.  You probably shouldn't be using 
> a buffering readFile for files that big.
>
> On Wed, May 16, 2012 at 10:23 AM, Joran Greef <[email protected]> wrote:
>
>> Granted, max buffer size on Mac is about (42949672 * 25) bytes and this 
>> doesn't deal with files bigger than that (about a GB), but then I think 
>> neither does fs.readFile (perhaps this needs to be fixed).
>
>
>

Reply via email to