-
Notifications
You must be signed in to change notification settings - Fork 36
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
Speed up UFOZ read/write. #221
Comments
@anthrotype, I'm going to do my studying here and if it does require a change in ufoLib, I'll make an issue for discussion and proposal over there. I figured it'd be best to consolidate it here for now since defcon is where the problem is most acute as of this moment. |
sounds good |
This is the current read process inside of UFOReader:
Inside of When a file that was not read during This is the current write process inside of UFOWriter:
This is a very expensive process. In my test case of one style of Source Serif Pro (1415 glyphs) the write time is always a minimum of around two seconds. That's just the overhead of the write process as it is currently structured. I've analyzed this and it breaks down like this:
The obvious solution to this is to retain Further complicating things is the possibility of external changes to the UFOZ by another application/process. When reading from My current idea is to modify the write process so that part of the work can be reused. The logic would be like this:
Using the timed results from above, during the first save, the time should break down like this:
And subsequent saves should break down like this:
This will reduce the overhead on subsequent saves by half. If an external change is made, we need to discard the retained temporary file system redo step 1 as the temporary file system is no longer in sync. I think there may be more optimizations possible, but this is what I have for now. I haven't yet worked out how this logic would be distributed to defcon and ufoLib. I'm going to do more thinking and testing before I get into that. |
Below is an outline of what I am going to try first. If this works, there will be no changes needed in ufoLib. All of these changes would be applicable only to defcon's First, I'd establish a defcon specific version of ZipFS. This will be used for reading only: from fs.zipfs import ReadZipFS
class DefconZipFS(ReadZipFS):
def __init__(self, *args, writableFS=None, **kwargs):
self.writableFS = writableFS
super(DefconZipFS, self).__init__(*args, **kwargs)
def getbytes(self, path):
if self.writableFS.exists(path):
return self.writableFS.getbytes(path)
data = super(DefconZipFS, self).getbytes(path)
self.writableFS.setbytes(path, data)
return data In
When creating a
This will produce the following behavior when anything is read from the
In
This behavior should be off by default and may be activated via a kwarg in There are situations that need to be handled that I don't have answers for yet:
|
Reading and writing UFOZ is extremely slow when only part of the wrapped UFO data have been modified. This is partly due to some issues in ufoLib (which I will address separately) but the changes that I am studying for ufoLib will need to be deeply integrated within defcon.
This issue is a public notepad for my examinations and tests. I'll be updating the tasks and results in the comments of this issue.
The text was updated successfully, but these errors were encountered: