<< Back to previous view

[TNS-44] Reload on a function-by-function basis for improved performance in large projects Created: 24/Jul/16  Updated: 24/Jul/16

Status: Open
Project: tools.namespace
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Alex Gunnarson Assignee: Stuart Sierra
Resolution: Unresolved Votes: 0
Labels: enhancement


 Description   

CURRENT SITUATION

Currently tools.namespace reloads portions of a given Clojure project on a file-by-file (really, namespace-by-namespace) basis. While it works great and performs quite well for most projects — ones which feature namespaces which compile quickly, dependency graphs which don't have too many nodes, and/or dependency graphs which aren't very deep — developers experience a (potentially) significant slowdown the less the project conforms to these three features.

POTENTIAL SOLUTION

A potential solution is this:

  • Walk the forms in all the project's namespaces (significant up-front cost but amortized with incremental reloads)
  • Create a dependency graph of (namespaced, non-local) vars, not just namespaces
  • Detect whether a var's compile-time value (e.g. in the case of a `defn`, its metadata, params, and unevaled body) has changed
  • If so:
  • Reload all the vars which depend on it (according to the dependency graph previously created)
  • Compile it
  • Update the dependency graph
  • Detect whether a var has been added/created
  • If so:
  • Compile it
  • Update the dependency graph

As for tests, it would be nice to re-run only the tests affected by a change to a var, not all the tests in that namespace every time the namespace changes at all.

Essentially, this feature would increase reload granularity (and reload speed) in the same way that namespace-reloading increases granularity (and speed) from recompiling the entire project.



 Comments   
Comment by Alex Gunnarson [ 24/Jul/16 10:27 AM ]

Sorry, the nested lists got messed up. Should be:

  • Walk the forms in all the project's namespaces (significant up-front cost but amortized with incremental reloads)
  • Create a dependency graph of (namespaced, non-local) vars, not just namespaces
  • Detect whether a var's compile-time value (e.g. in the case of a `defn`, its metadata, params, and unevaled body) has changed
    • If so:
      • Reload all the vars which depend on it (according to the dependency graph previously created)
      • Compile it
      • Update the dependency graph
  • Detect whether a var has been added/created
    • If so:
      • Compile it
      • Update the dependency graph




Generated at Sat Jul 30 04:27:04 CDT 2016 using JIRA 4.4#649-r158309.