Skip to content

ZJIT: Function Lifecycle #1031

Description

@k0kubun

Purpose

  • Design a state machine for function lifecycle that maximizes the performance of ZJIT.
  • Every state transition of a function should have a tuning knob that can be tuned easily.

Considerations

Possible tuning knobs to consider when designing function lifecycle:

  • State transition:
    • How many times should we profile (or run non-profiling cycles) before compiling a version?
    • What kind of events (certain kinds of exits or invalidations) should trigger recompilation?
  • Versioning:
    • How many versions should we compile for each function?
    • What compilation policy should we use for each version?
  • Profiling
    • Should we have a profiling tier in JIT?
      • Can it profile something that the interpreter can't profile?
      • Would we afford to collect more profiles if we profiled faster?
      • How much extra memory do we need to generate JIT code for profiling?
    • Are there anything we aren't profiling but is profitable for JIT?
      • Branch probability
      • Profiles on a megamorphic ISEQ that is inlined by multiple JIT functions

TODO

  • Research what kind of design decisions existing compilers made for the above design space and why.
  • Make sure we have a tuning knob for everything we're interested in tuning.
    • Are function stubs compiling the callee immediately, not running enough profiling cycles?
    • Do we run the intended amount of cycles after resetting the call counter on invalidation or a recompile exit?
  • Attempt to encapsulate the state machine in a single module, which makes it easier to trace, understand, and modify that.
  • Make sure we don't miss optimization opportunities due to no profiles or compiling too early in benchmarks and SFR/Core.
    • Where are we seeing no-profiles right now?

Metadata

Metadata

Assignees

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