Uploaded image for project: 'Clojure'
  1. CLJ-1384

clojure.core/set should use transients

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: Release 1.6, Release 1.5
    • Fix versions: Release 1.7
    • Labels:
    • Approval:
      Ok
    • Patch:
      Code

      Description

      CLJ-1384-p2 uses transients for both create and createWithCheck. This is consistent with the current implementation for map.

      clojure.core/vec calls (more or less) PersistentVector.create(...), which uses a transient vector to build up the result.

      clojure.core/set on the other hand, calls PersistentHashSet.create(...), which repeatedly calls .cons on a PersistentHashSet, with all the associated speed/GC issues.

      Operation count now w/transients
      set 5 1.771924 µs 1.295637 µs
      into 5 1.407925 µs 1.402995 µs
      set 1000000 2.499264 s 1.196653 s
      into 1000000 0.977555 s 1.006951 s

      Patch: CLJ-1384-p2.patch
      Screened by: Stu

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gfredericks gfredericks
            • Votes:
              4 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: