Skip to content

Performance issues with merge functions for containers #665

@yihozhang

Description

@yihozhang

Merge functions are often used with containers like Set to track things like sets of free variables or to implement aggregation (with set-contains). However, they are currently very slow for non-trivial workloads:

Both of the programs below require gigabytes of memory and never finish.

(sort IntSet (Set i64))
(relation R (i64))
(function f () IntSet :merge (set-union old new))

(R 0)
(rule 
    ((R i) (< i 50000))
    ((R (+ i 1))
     (set (f) (set-of i))))

(run-schedule
    (saturate (run)))

(sort IntSet (Set i64))
(relation R (i64))
(function f () IntSet :merge (set-union old new))

(R 0)
(ruleset init)
(rule 
    ((R i) (< i 50000))
    ((R (+ i 1)))
    :ruleset init)

(rule ((R i))
      ((set (f) (set-of i))))


(run-schedule
    (saturate (run init)
    (run)))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions