Assoc library in c (or C++)

Hello,

I started to examine my program for performance. Since i am making heavy use of assoc (and its relational “reading” ) i am wondering if there could be a significant performance advantage if the assoc library would be implemented in C (or C++?).

Any thoughts would be much appreciated,

thank you,

Dan

If the time spent is mostly lookup, the performance difference will not be big.

You need to understand the use case and profile to see where the time goes. If you often insert and remove items from the assoc, it will have to re-balance and this is written in Prolog.

On the other hand, if you are not inserting and removing often, you might even try to use dicts and see if that makes a difference.

So if you can see what is currently the bottle neck and understand your use case, it will be easier to make a decision before investing time into writing more code.

Hi Boris,

Thank you for your explanation – thats very helpful.

Indeed, i am heavily using it for read and write operations all the time. Less for removal though, since usually that happens due to backtracking.

So, rebalancing is an expensive operation that could see a speed up with c or c++?

Dan

Do you have any idea how much of the total time of your test case goes into adding items to the assoc? Or for lookup? Once you know that you can at least put a hard upper limit to the possible benefits of optimizing this particular part of your program.

I hope i am reading the profile data correctly.

For one use case when i order “cumulative profile by time”, then “addkey” is about 17% and “lookup” around 16%

the rest of the time is sort of evenly distributedl no particular “hotspot” as far as i can see

thinking about it – assoc is involved more than 30% of the computational time … that seems quite significant to me - i guess this is an area i should think about very carefully.