Clojure

Speed up dissoc on array-maps

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.8
  • Component/s: None
  • Labels:
  • Patch:
    Code
  • Approval:
    Ok

Description

The method PersistentArrayMap.without() first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.

Approach: Remove the unnecessary comparison.

Patch: clj-1295-2.patch

Screened by: Alex Miller

  1. clj-1295-1.diff
    15/Nov/13 7:05 PM
    1 kB
    Andy Fingerhut
  2. clj-1295-2.patch
    09/Oct/15 8:45 AM
    2 kB
    Alex Miller

Activity

Andy Fingerhut made changes -
Field Original Value New Value
Attachment clj-1295-1.diff [ 12465 ]
Andy Fingerhut made changes -
Patch Code [ 10001 ]
Andy Fingerhut made changes -
Description In latest Clojure master as of Nov 15 2013, the method without() in PersistentArrayMap.java first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being remove, even though its location is already stored in i.
In latest Clojure master as of Nov 15 2013, the method without() in PersistentArrayMap.java first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.
Alex Miller made changes -
Approval Triaged [ 10120 ]
Alex Miller made changes -
Priority Minor [ 4 ] Major [ 3 ]
Alex Miller made changes -
Labels performance ft performance
Description In latest Clojure master as of Nov 15 2013, the method without() in PersistentArrayMap.java first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.
In latest Clojure master as of Nov 15 2013, the method without() in PersistentArrayMap.java first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.

*Screened by:* Alex Miller
Rich Hickey made changes -
Fix Version/s Release 1.8 [ 10254 ]
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Alex Miller made changes -
Attachment clj-1295-2.patch [ 15203 ]
Description In latest Clojure master as of Nov 15 2013, the method without() in PersistentArrayMap.java first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.

*Screened by:* Alex Miller
The method PersistentArrayMap.without() first searches for a matching key using indexOf(key) and saves the result in i.

If a matching key was found, the code then copies the old array to the new smaller one, but unnecessarily repeats the comparison of every key in the map to the key being removed, even though its location is already stored in i.

*Approach:* Remove the unnecessary comparison.

*Patch:* clj-1295-2.patch

*Screened by:* Alex Miller
Approval Vetted [ 10003 ] Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Completed [ 1 ]

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: