aset-* and aget perform poorly on multi-dimensional arrays even with type hints.

Description

Here's a transcript of the behavior. I don't know for sure that reflection is being done, but the performance penalty (about 1300x) suggests it.

One workaround is to use multiple agets.

Cause: The inlined version only applies to arity 2, and otherwise it reflects.

Environment

Clojure 1.5.1.

Dependencies: criterium

Activity

Show:
Alexander Yakushev
September 4, 2018, 2:59 PM

BTW, why does the docstring for aset says it works only on arrays of reference types? Is this comment outdated? We can fix it it along the way.

Alexander Yakushev
September 15, 2018, 8:53 AM

Is there a chance to review this for 1.10? Perhaps, the implementation is too complicated and needs more time to consider? I might try to reduce the scope then.

Alex Miller
September 17, 2018, 2:33 PM

It's complicated, not sure if its worth this or not. Probably won't look at it for 1.10.

Alexander Yakushev
September 17, 2018, 2:49 PM

Thanks for the answer. In terms of complexity, I can remove the part that "optimizes" reflective calls, which both simplifies the algorithm and makes the reflection sites visible to the compiler (and thus to the user).

Alexander Yakushev
July 31, 2019, 8:39 PM

Bump – can you consider picking this up again for 1.11? The patch is complete; however, if it seems too complicated, it can be simplified.

 

Assignee

Unassigned

Reporter

import

Labels

Approval

Triaged

Patch

Code

Affects versions

Priority

Critical
Configure