Affects Version/s: 8.6.2
Fix Version/s: None
Lucene Fields:New, Patch Available
FSDirectory uses an 8KB buffer and chunk size when writing to disk. The class has a comment explaining how file channels would do mallocs for larger chunks. However, that comment was originally introduced when RandomAccessFile and later FileOutputStream was used. Since the switch to file channels, there is no longer any difference (except the size of the buffer) for different buffer/chunk sizes.
Attached patch keeps the comment, clarifying that it is a historic reason.
Including my research here for background information in case this helps validate the change:
- The stack buffer for 8KB or below in the JDK is here:
This is used by both FileOutputStream and RandomAccessFile.
- This was applicable when the comment to lucene was added and later changed to FileOutputStream:
- Lucene cut over to nio here:
and the comment was later changed to say file channels here:
- File channels use thread local direct buffers instead, see sun.nio.ch.IOUtil.write, which uses Util.getTemporaryDirectBuffer to get a thread local buffer.