elpi icon indicating copy to clipboard operation
elpi copied to clipboard

Performance issues for maps

Open cmester0 opened this issue 4 months ago • 0 comments

When having large maps updating values gets very slow. The following code:

pred map_test_fold i:int, i:V, i:V, o:std.map int V.
map_test_fold I V U M :-
  std.fold
    {std.iota I}
    {std.map.make cmp_term}
    (k\m\ std.map.add k V m) /* insert */
    Mtemp,
  std.fold
    {std.iota I}
    Mtemp
    (k\m\ std.map.add k U m) /* update */
    M.

gets quite slow for e.g. I = 6000, V = {std.iote 20}, U = {std.iota 19}.

@gares id this might already be tested at https://github.com/LPCIC/elpi/blob/master/tests/suite/performance_FO.ml#L65-L80 .

When running the test it seems to copy the entire AVL tree for each update, instead of just the path. This might just the tree generating a lot of variables. Alternatively it might be copying data instead of using names/pointers.

cmester0 avatar Aug 13 '25 20:08 cmester0