After an 8 year break from Gramps, I’m looking at all of the changes and new things. Wow! But somethings haven’t changed. Gramps is still slow in some places. Why?
In order to refamiliarize myself with the codebase, I started to look at filters. @emyoulation kindly shared a large family tree to explore some specific oddities in filtering and searching. And now it begins to come back to me.
In this thread, I’ll document some issues and ideas as I explore anew.
First, I wanted to get a feel for how often Gramps touches the database. The first thing that I found was that on the Relationships page for a typical family (mom, dad, 3 siblings, and a spouse) the individual’s person data was accessed in the database 19 times. Yikes!
Accessing the database and unpickling the data 19 times is expensive, but is a result of how Gramps was designed.
I remembered that I had written a Cache proxy that is used in a few places in Gramps. So I wrapped any opened database with it. That helped somewhat, reducing this particular individual’s db access down to 6. (It also helps speed up all of the other lookups as well). But why didn’t it reduce the access down to 1?
Ah, there are two ways that we’d need to cache data: at the database level, and at the Gramps Object level (objects like Person, and Place). We do the second with the Cache proxy, but not the first. I’ll explore that possibility.
But why don’t we always cache? Currently, the Cache proxy is a read-only layer (which is why it is only used in a few places). But with a little engineering, we can fix that so that we always cache. This would help across the board, with regular access and filters.