Skip to content

Faster startup -- Experiment B -- streamline and tweak #65

Closed
@gvanrossum

Description

@gvanrossum

This is a placeholder for a description of Experiment B (see #32 (comment))

  • try to speed up unmarshalling of code objects by low-level optimizations

  • streamline code objects (fewer redundant, computed fields; fewer small objects)

  • opcodes for immediate values:

    • MAKE_INT creates an int from oparg; for 0-255 this is a sure "integer cache" hit that we can inline
    • LOAD_COMMON_CONSTANT: oparg indexes in a second switch (or array?) with shared immutable common constants, e.g.
      • 0: None
      • 1: False
      • 2: True
      • 3: Ellipsis
      • 4: AssertionError (subsumes LOAD_ASSERTION_ERROR)
      • 5: ''
      • 6: ()
      • 7-11 (or some other range): negative values -1 through -5 (also sure hits in the integer cache)

    Benefit of MAKE_INT and LOAD_COMMON_CONSTANT is that they reduce the size of co_consts (and hence of PYC files) without adding to the size of the instruction array. Downside is that the speed and simplicity of LOAD_CONST is hard to beat, so it will be hard to measure the difference in benchmarks. But None, False, True and small ints make up a lot of the constants (we can easily do research on this).

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