Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Completed
-
Affects Version/s: Release 1.7
-
Fix Version/s: Release 1.7
-
Component/s: None
-
Labels:
-
Patch:Code
-
Approval:Ok
Description
Compilation speed has been a real problem for a number of my projects, especially Aleph [1], which in 1.6 takes 18 seconds to load. Recently I realized that Class.forName is being called repeatedly on symbols which are lexically bound. Hits on Class.forName are cached, but misses are allowed to go through each time, which translates into tens of thousands of calls after calling `(use 'aleph.http)`.
Proposed: Avoid calling Class.forName() on non-namespaced symbols that do not contain "." or start with "[", don't map to a Class in the ns, and are names in the current local env. Also, adjust the ordering of checks in tagToClass to check for hints before checking for class.
[Note that the latest variant of the patch moves the check from the original patch farther down in the logic to avoid changing the semantics. This still yields virtually all of the performance gains. See comments for details.]
Patch: clj-1529-no-cache-2.diff
Screened by: Stu Halloway. Note that for this change the patch ended up being so small it is easier follow the code than the prose description.
One of our larger projects (not macro-laden) just went from 36 seconds to 23 seconds to start with this patch.