Skip to content

Performance of instance-precondition on JVM #454

Description

@frenchy64

Clojure compiles (let [cls String] (instance? klass "a")) less optimally than (instance? String "a"). This affects this line, which I imagine is a pretty hot code path in schema usage:

#?(:clj #(instance? klass %)

The perf difference seems roughly 2x.

examples.server=> (time (dotimes [_ 10000] (let [cls String] (instance? cls "a"))))
"Elapsed time: 1.142388 msecs"
nil
examples.server=> (time (dotimes [_ 10000] (instance? String "a")))
"Elapsed time: 0.411797 msecs"
nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions