Skip to content

Performance Design Guidlines

Vlad Balin edited this page May 27, 2015 · 6 revisions

All rules in brief

  • Don't use literal objects where constructors can be used.
  • Model.attributes and __attributes must be an object. Operations deoptimizing it to hash must be avoided.
    • All known elements must be initialized in constructor in the same order.
    • On new models, id attribute must exist but set to undefined.
    • Always use dedicated constructors for these objects copy and creation.
    • Never delete elements from attributes.
  • Function's arguments
    • Don't write to function arguments
    • Don't pass 'arguments' object through, except for apply.
    • Avoid using 'arguments' in hot spots, create specialized functions instead.
  • Functions general rules
    • Avoid generic functions, rely on attributes and model type information whenever possible.
    • Use ad-hoc polymorphic functions only when necessary.
    • Split ad-hoc polymorphic functions to the set of type-specialized functions.
    • Avoid long functions.
    • Move for-in loops operating on hash in separate functions.
    • Avoid exceptions
    • Use loop unrolling with compilation to Function for hot spots.
  • 1
  • 2
  • 3
Clone this wiki locally