erkyrath / lectrote

The IF interpreter in an Electron shell
Other
248 stars 28 forks source link

Files need to be less aggressively output buffered #85

Open curiousdannii opened 7 years ago

curiousdannii commented 7 years ago

Lectrote is currently heavily buffering output to data files.

On Ubuntu it seems to flush every 256 bytes. On Windows it seems to write out 4Kb blocks, but only when you quit Lectrote.

In neither OS will it flush the buffer when you quit (so if your command file doesn't reach 4Kb in Windows nothing will be recorded.) Neither do they flush the buffer after a certain amount of time.

It is of course essential that all the data actually gets written. As long as it does that the method of buffering doesn't matter, but from my user's perspective, I'd prefer a time based approach rather than a data length approach. (Or Lectrote could not bother buffering and let the OS handle it.)

erkyrath commented 7 years ago

Let me see... I am calling the Node fs.writeSync function for all writes. (https://nodejs.org/api/fs.html#fs_fs_writesync_fd_buffer_offset_length_position) I don't see a flush function in the API to add to that? Unless I've screwed up the sequencing of my own fflush method, this may be a Node problem.

curiousdannii commented 6 years ago

I don't think this is waiting on an electron fix because it happens when I use electrofs.js in pure Node.

erkyrath commented 6 years ago

"Waiting on node fix" is what I meant, but the label is close enough.