clojure-dev

Ben Sless 2023-06-28T16:35:59.617849Z

I decided to pick up the glove regarding the ask issue I opened map equivalence using kvreduce, and I have a couple of questions, one practical, one less so • all the functional tests pass. How would you test performance improvements? • I find that I really dislike my implementation, it has about 8x the amount of code I would have wanted. Once for equals/equiv, once for java.util.Map/IPersistentMap. Additionally, since APersistentMap doesn't implement kvreduce, the core implementation is duplicated between PersistentArrayMap and PersistentHashMap. GAH, how do I clean this up?

Alex Miller (Clojure team) 2023-06-28T16:39:03.960229Z

Link?

Ben Sless 2023-06-28T16:42:43.958849Z

haven't pushed to git yet

Ben Sless 2023-06-28T16:44:54.911449Z

this is the gist:

Ben Sless 2023-06-28T16:45:11.542439Z

Ben Sless 2023-06-28T16:57:35.998689Z

maybe I could unify the implementations if I implement getOrDefault on APersistentMap

Ben Sless 2023-06-28T17:02:17.807009Z

yeah that counts down on the duplication

Alex Miller (Clojure team) 2023-06-28T17:07:34.095629Z

I mean, link to the issue

Ben Sless 2023-06-28T17:08:00.505819Z

oh

Ben Sless 2023-06-28T19:37:40.398409Z

To run the benchmarks without interference with external tools I went with

clojure -A:CLOJURE_VERSION -M src/io/github/bsless/map_equiv.clj
Ran with criterium, to get a feel for the results

Ben Sless 2023-06-28T19:42:22.219049Z

(spoiler, my patch looks way faster, better than 2-3x for maps of 1-128 elements)

Ben Sless 2023-06-28T19:43:11.632619Z

Need to construct test cases and acceptable benchmarking methodology

Alex Miller (Clojure team) 2023-06-29T00:06:08.129829Z

you need to step back and be categoric about what you're finding. 1. why is it faster, just logically? 2. what abstractions that already exist in Clojure convey those capabilities or constraints? I think if you can answer those questions, you will be on the path to an actual problem. Once you have a well-stated problem, you can then easily come up with some new ideas for multiple places you could make changes. Then, make a table that compares those and evaluates the tradeoffs. I suspect there will be one or maybe two leading options. I would not bother to write any code until then, as it's probably the wrong code. If you want to walk down this process, I am happy to do this work async with you, but answer the questions above as clearly as possible first.

👍 1
Ben Sless 2023-06-29T03:24:45.416559Z

Tyvm Alex, I'll take you up on this offer