4.4.1 improves performance and fixes important bugs

4.4.1 improves performance and fixes important bugs

By | 2018-01-07T11:11:55+00:00 January 5th, 2018|Uncategorized|0 Comments

Today we are releasing Gallery Server 4.4.1. While it includes no new features, it improves performance in several key areas and fixes a few important bugs. We recommend migrating to it immediately, especially since upgrading from 4.X is as easy as copying the files from the upgrade package over your existing files.

Performance gains

We spent a lot of time profiling Gallery Server, looking for performance bottlenecks in various configurations, from small galleries using SQL CE to large, multiple gallery environments with 1,000,000 assets. We found several opportunities were we could more narrowly purge the cache after certain changes, thereby preventing Gallery Server from having to reload data that didn’t actually change.

Gallery Server uses an in-memory cache to store a list of galleries and all the album IDs in each. This is expensive to rebuild, especially because reloading it causes a validation routine to run that ensure the integrity of several database tables.

Beginning in 4.4.1, the gallery cache is no longer cleared when assigning an album thumbnail, syncing an album if there are no changes to the album, uploading files to an album, and a few other cases. The speed improvement will be most dramatic in very large, multiple gallery installations.

We also identified areas where we were persisting data structures to the database when nothing had actually changed. By more accurately identifying changed data, we reduced the number of times we had to call the database. This improvement is most noticeable when using SQL CE, since it is a rather slow database engine compared to SQL Server.

Bug fixes

We were finally able to track down the root cause of a nasty bug we’ve been trying to fix for some time. We did it with significant help from one of our customers, Reto Ambühler in Switzerland. Reto has a large, multiple gallery database that was frequently exhibiting the issues that had only rarely been reported from others, and never been reproducible. Reto shared the database with us and we were finally able to reproduce the behavior. Thank you Reto, for your time and patience.

It boiled down to a faulty lock mechanism when reloading the gallery cache from the database. The issue only appeared when multiple galleries were used and in certain multi-threaded scenarios. Depending on how users were interacting with the gallery, they saw a variety of failures, but they all had this same cause.

  • A page may be randomly assigned to another gallery
  • User may receive error “Invalid state of GalleryServerRole instance”
  • Role/album relationships may disappear

We fixed the lock mechanism and are confident we’ve finally seen the last of these errors.

Safer file moves – Just before releasing 4.4.1, a customer reported getting the error “cannot create a file when that file already exists” when rotating an image. After investigating and consulting StackOverflow, we learned that antivirus software and certain scenarios with multiple threads could cause an issue when replacing an existing file. So we reworked the move file routine to include retry logic up to 10 times with a 500 ms delay between attempts. We also save a backup of the original file and restore it if the move ultimately fails.

False error messages – When an image is edited, Gallery Server often has to create a new image, copy the metadata properties, delete the original, and finally move the newly created image into the same place as the original. We noticed that the metadata copy routine would falsely generate the error “This codec does not support the specified property” when an image did not have any tags (keywords) or the date picture taken property. This error was hidden from the user, but it was logged in the event log and an email was sent to administrators. We updated the routine to avoid this error.

A side benefit to fixing this is that by not logging the false errors, editing performance improves. In one of our tests involving rotating fifty 100 KB images, the elapsed time dropped from 1 minutes 28 seconds to 5 seconds.

A complete list of bug fixes and details about each one can be found in the 4.4.1 Fixed Defect Report.

How to apply this update

If your existing gallery is 4.X, upgrading is easy — just copy the files from the upgrade package over your existing installation. There are no web.config changes to merge and you don’t have to worry about the version_key.txt file or your license information. Get the upgrade package from your downloads page. If you are upgrading from an earlier version, follow the instructions in the Admin Guide.

About the Author:

Founder and Lead Developer of Gallery Server

Leave A Comment