ClojureScript

Transient support for PersistentHashMap

Details

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

Description

Follow-up to CLJS-178 (the ClojureScript port of Clojure's PersistentHashMap) introducing transient support for PersistentHashMap.

The attached patch applies cleanly on top of the latest transient-less patch from CLJS-178. The code is also viewable on GitHub – here's the current branch:

https://github.com/michalmarczyk/clojurescript/tree/phm2-transient

And here's a jsPerf test comparing PHM vs. THM on the task of building a map of 10000 entries (with THM being twice as fast in Chrome):

http://jsperf.com/cljs-persistent-hash-map-transient-support

Activity

Hide
David Nolen added a comment -

Nice, could we add some tests?

Show
David Nolen added a comment - Nice, could we add some tests?
Hide
Michał Marczyk added a comment -

Sure, I'll get onto it tonight.

Show
Michał Marczyk added a comment - Sure, I'll get onto it tonight.
Hide
Michał Marczyk added a comment -

Same code as the previous patch but applies on top of the current master.

Here's a branch for convenience:

https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration

Will do the tests now.

Show
Michał Marczyk added a comment - Same code as the previous patch but applies on top of the current master. Here's a branch for convenience: https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration Will do the tests now.
Hide
Michał Marczyk added a comment -

The new 0001-... patch fixes a couple of typos which prevented {dissoc!} and {get} from working with TransientHashMap.

The 0002-... patch introduces a suite of tests for PHM & THM. Happily the PHM passes them all without modification.

Show
Michał Marczyk added a comment - The new 0001-... patch fixes a couple of typos which prevented {dissoc!} and {get} from working with TransientHashMap. The 0002-... patch introduces a suite of tests for PHM & THM. Happily the PHM passes them all without modification.
Hide
Michał Marczyk added a comment -
Show
Michał Marczyk added a comment - Oh, one more thing – here's the new branch: https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration-2
Hide
Michał Marczyk added a comment -

A cleaner patch w/ tests w/o an unnecessary assertion msg. Branch @

https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration-3

Show
Michał Marczyk added a comment - A cleaner patch w/ tests w/o an unnecessary assertion msg. Branch @ https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration-3
Hide
Michał Marczyk added a comment -

Hm, actually I missed one thing in the tests – hash collisions. Will prepare a new patch in a moment.

Show
Michał Marczyk added a comment - Hm, actually I missed one thing in the tests – hash collisions. Will prepare a new patch in a moment.
Hide
Michał Marczyk added a comment -

Just a heads-up – apparently there's something the matter with hash collision handling in transients. Will attach a new patch once I get this sorted.

Show
Michał Marczyk added a comment - Just a heads-up – apparently there's something the matter with hash collision handling in transients. Will attach a new patch once I get this sorted.
Hide
David Nolen added a comment - - edited

Moving forward could we replace the patches instead of always adding new ones? It makes it very hard to figure out which one to use especially on tickets that have a long life like the original PHM one.

Show
David Nolen added a comment - - edited Moving forward could we replace the patches instead of always adding new ones? It makes it very hard to figure out which one to use especially on tickets that have a long life like the original PHM one.
Hide
Michał Marczyk added a comment -

Oh. Sure thing. I'll replace the whole lot once I've got the new patch ready then.

Show
Michał Marczyk added a comment - Oh. Sure thing. I'll replace the whole lot once I've got the new patch ready then.
Hide
Michał Marczyk added a comment -

These patches apply cleanly against the current master. The current branch is @

https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration-5

Show
Michał Marczyk added a comment - These patches apply cleanly against the current master. The current branch is @ https://github.com/michalmarczyk/clojurescript/tree/phm-transient-integration-5

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: