Slow file loading due to pricedb enhancement

Kevin Osinski kjoblog1 at sbcglobal.net
Mon Feb 21 12:20:53 EST 2005


After I upgraded from 1.8.9 to 1.8.11, the amount of
time it takes to load my data at startup went up
dramatically.  After reading through the change logs
and doing some experiments, I isolated as the culprit
the change to gnc-pricedb.c in 1.8.10, which added
price_list_is_duplicate().

My data file has a large number of pricedb entries, as
I like to keep all my history around so I can track
changes to the values of my holdings.  If I understand
the gnc-pricedb code, price_list_is_duplicate() adds
an O(n^2) operation to the creation of the pricedb,
which is bad for a potentially large list.  In order
to find duplicate entries, it sequentially searches
the price list for the specified commodity. 
Unfortunately, the most common case is also the worst
for performance:  failing to find a match means
looking at every price in the list (for a given
commodity).

Any thoughts on the best way to fix this?  Why was
this code added -- was it just good housekeeping, or
were duplicate pricedb entries causing problems
elsewhere?  I currently don't have a GnuCash
development environment set up, but I might be
inspired to do so in order to fix this problem.

Thanks,

Kevin


More information about the gnucash-devel mailing list