Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kryo memoizer #465

Merged
merged 45 commits into from Apr 26, 2013
Merged

Kryo memoizer #465

merged 45 commits into from Apr 26, 2013

Conversation

joshmoore
Copy link
Member

loci.formats.Memoizer is a new ReaderWrapper implementatino which memoizes, or cache, all calls to IFormatReader.setId(String) by writing out the internal IFormatReader delegate using http://kryo.googlecode.com.

Typical usage is to add Memoizer as one of the outermost ReaderWrappers:

Memoizer m = new Memoizer(new MinMaxCalculator());
try {
  m.getMemoFile(filename); // Where the file will be saved.
  m.setId(filename);
  m.isSavedToMemo();
} finally {
  m.close();
}

Files are currently never cleaned up, and exceptions are ignored. Instead, bad memo files should likely be actively deleted.

joshmoore and others added 29 commits April 18, 2013 01:04
Rather than writing directly to the memoFile location,
write to a tempFile that's located in the same directory
and then use File.renameTo to move it. Any errors in
writing or renaming will prevent caching.
MetadataStore instances should now be kept in the Memoizer
itself and not passed down into further ReaderWrappers. On
load and save, copying is done from an OME-XML based impl.

It was unclear to me if there were other points at which
synchronization between the two needed to take place.
'boolean FormatTools.equalReaders(IFormatReader, IFormatReader)' returns
whether or not the two readers are considered to be equivalent.  The
internal reader wrapper stack and state must be equal in order to return
true.
We only need to compare uninitialized state, not the initialized state.
By having the Closeable interface implemented, locations
where "close()" is not called in a finally can be detected
by findbugs, eclipse, etc.
The close method is likely not needed, but is more
strictly correct. It was added in an attempt to find
the cause of a segfalt.
The finalizer of the java.util.zip.Inflater class
was frequently though non-deterministically causing
the loading of memo files to segfault the JVM. By
marking the field transient, it's no longer being
serialized, and therefore not deserialized.
If directory is set, all files will be created as absolute
paths under it with all parent paths automatically created.
If the directory is set but does not exist, memoization is
disabled. This is useful for periodically turning off memos
for comparing performance.
@joshmoore
Copy link
Member Author

Rebased to solve grey button issue and to make turbojpeg available on the omero branch

@melissalinkert
Copy link
Member

Travis build failing due to Kryo not being added to the relevant pom.xml

}

public void saveVersion(Integer vERSION) {
kryo.writeObject(output, VERSION);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be kryo.writeObject(output, vERSION)?

@melissalinkert
Copy link
Member

Findbugs still unhappy: http://hudson.openmicroscopy.org.uk/view/Bio-Formats/job/BIOFORMATS-per-commit-test/353/

Opening a PR against this one in a few minutes to hopefully sort that out.

joshmoore and others added 11 commits April 18, 2013 11:18
Otherwise, on deserialization the following exception is
thrown:

```
Exception in thread "Thread-14" java.lang.NullPointerException
    at java.util.logging.LogManager.access$900(LogManager.java:130)
    at java.util.logging.LogManager$RootLogger.getHandlers(LogManager.java:979)
    at java.util.logging.LogManager.resetLogger(LogManager.java:677)
    at java.util.logging.LogManager.reset(LogManager.java:665)
    at java.util.logging.LogManager$Cleaner.run(LogManager.java:223)
```
It's not serializable, and does not offer much in terms of performance
improvements.
Works around Kryo issue 100.
Merging in develop in order to fix the travis compilation.
@joshmoore
Copy link
Member Author

Merged in develop to fix genshi.

melissalinkert added a commit that referenced this pull request Apr 26, 2013
@melissalinkert melissalinkert merged commit 4d5d6e8 into ome:develop Apr 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants