Clojure

faster, more flexible dispatch for clojure.walk

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code

Description

The conditional dispatch in clojure.walk is slow and not open to extension. Prior to CLJ-1105 it did not support records.

Approach: Reimplement clojure.walk using protocols. The public API does not change. Users can extend the walk protocol to other types (for example, Java collections) if desired. As in CLJ-1105, this version of clojure.walk supports records.

Patch: 0002-CLJ-1239-protocol-dispatch-for-clojure.walk.patch

Performance: My tests indicate this is 1.5x-2x the speed of the original clojure.walk. See https://github.com/stuartsierra/clojure.walk2 for benchmarks.

Risks: This approach carries some risk of breaking user code that relied on type-specific behavior of the old clojure.walk. When running the full Clojure test suite, I discovered (and fixed) some breakages that did not show up in clojure.walk's unit tests. See, for example, commit 730eb75 in clojure.walk2

Activity

Stuart Sierra made changes -
Field Original Value New Value
Assignee Stuart Sierra [ stuart.sierra ]
Stuart Sierra made changes -
Patch Code and Test [ 10002 ]
Description The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API remains unchanged. After this patch, clojure.walk supports records, but still does not support non-Clojure types such as Java arrays or collections.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks.
Attachment 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch [ 12078 ]
Stuart Sierra made changes -
Description The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API remains unchanged. After this patch, clojure.walk supports records, but still does not support non-Clojure types such as Java arrays or collections.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks.
The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API is unchanged, but {{walk}} gains support for records. Users can extend the {{walk}} protocol to other collection types if desired.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks. My tests indicate it is roughly 2x the speed of the original clojure.walk.
Stuart Sierra made changes -
Description The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API is unchanged, but {{walk}} gains support for records. Users can extend the {{walk}} protocol to other collection types if desired.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks. My tests indicate it is roughly 2x the speed of the original clojure.walk.
The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API is unchanged, but {{walk}} gains support for records. Users can extend the {{walk}} protocol to other collection types if desired.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks. My tests indicate it is roughly 2x the speed of the original clojure.walk.

This approach carries more risk of breaking user code than the patch in CLJ-1105. When running the full Clojure test suite, I discovered (and fixed) some breakages that did not show up in clojure.walk's unit tests. See [Extend to EmptyList - 730eb75 - stuartsierra/clojure.walk2|https://github.com/stuartsierra/clojure.walk2/commit/730eb756dcc424aa535d0872bd626079955c3892]
Alex Miller made changes -
Labels walk
Stuart Sierra made changes -
Patch Code and Test [ 10002 ] Code [ 10001 ]
Description The conditional dispatch in clojure.walk is slow and not open to extension. It also doesn't support records; see CLJ-1105.

*Current patch:* 0001-CLJ-1239-protocol-dispatch-for-clojure.walk.patch reimplements clojure.walk using protocols.

The public API is unchanged, but {{walk}} gains support for records. Users can extend the {{walk}} protocol to other collection types if desired.

This patch supersedes CLJ-1105 "clojure.walk should support records."

See https://github.com/stuartsierra/clojure.walk2 for benchmarks. My tests indicate it is roughly 2x the speed of the original clojure.walk.

This approach carries more risk of breaking user code than the patch in CLJ-1105. When running the full Clojure test suite, I discovered (and fixed) some breakages that did not show up in clojure.walk's unit tests. See [Extend to EmptyList - 730eb75 - stuartsierra/clojure.walk2|https://github.com/stuartsierra/clojure.walk2/commit/730eb756dcc424aa535d0872bd626079955c3892]
The conditional dispatch in clojure.walk is slow and not open to extension. Prior to CLJ-1105 it did not support records.

*Approach:* Reimplement clojure.walk using protocols. The public API does not change. Users can extend the {{walk}} protocol to other types (for example, Java collections) if desired. As in CLJ-1105, this version of clojure.walk supports records.

*Patch:* 0002-CLJ-1239-protocol-dispatch-for-clojure.walk.patch

*Performance:* My tests indicate this is 1.5x-2x the speed of the original clojure.walk. See https://github.com/stuartsierra/clojure.walk2 for benchmarks.

*Risks:* This approach carries some risk of breaking user code that relied on type-specific behavior of the old clojure.walk. When running the full Clojure test suite, I discovered (and fixed) some breakages that did not show up in clojure.walk's unit tests. See, for example, [commit 730eb75 in clojure.walk2|https://github.com/stuartsierra/clojure.walk2/commit/730eb756dcc424aa535d0872bd626079955c3892]
Attachment 0002-CLJ-1239-protocol-dispatch-for-clojure.walk.patch [ 12543 ]

People

Vote (4)
Watch (4)

Dates

  • Created:
    Updated: