Nick Fisher's tech blog

I/O

Improving Java IO Performance: Caching Data, When Appropriate

The sample code for this post can be found on GitHub.

The biggest bottleneck with I/O resources on the filesystem is the operating system, which controls access to the filesystem. Reading from, and writing to, the operating system, is much more expensive than storing data in memory, and that is the subject of this post: caching.

Improving Java IO Performance: Appropriately Using Random Access Over Streams

The sample code for this blog post can be found on GitHub.

A flavor I/O performance optimization that applies specifically to the filesystem is the decision on when to use Random Access instead of something like a BufferedInputStream. Random access allows for accessing a file in a similar way as a large array of bytes stored on the filesystem. From the oracle documentation on the RandomAccessFile class:

Improving Java IO Performance: Formatting Costs

The sample code associated with this blog post can be found on GitHub.

Another potential source of I/O bottlenecks, across any medium, could be the process you choose to format the data in in the first place. For example, XML used to be a standard way to send information across the wire or store in a backend system, but the size overhead of XML as compared to JSON is about double (not to mention it’s somehow harder to read when formatted compared to JSON).

Java IO: Paths and Files

The sample code for this repository can be found on Github.

System paths and file manipulation, usually within the java.nio package, in Java allow you to forgo some of the details related to streaming of files–which, while they offer low level details and optimization opportunities, typically take longer to develop and get right.

Java IO: Zip Archive Manipulation

The sample code associated with this post can be found on Github.

A ZIP file format is a compressed, lossless archive of files of files and/or directories. While the content being compressed will matter as to the algorithm’s effectiveness, it is a common way to transfer files among peers, particularly on many windows machines.

Java IO: Input Streaming

The sample code associated with this post can be found on Github.

In Java, the input and output stream abstraction can be used with file systems or across networks. While a lot of these abstractions have been abstracted even further away with modern libraries and tools (via servlets, for example), understanding the basics makes solving things like performance issues a little easier to wrap your head around.