Skip to content

Could TypingTransformer be more efficient? #519

Open
@retronym

Description

@retronym

In https://github.com/scala/scala/compare/2.13.x...retronym:faster/transformer-faster?expand=1, I demonstrate an idea I've had for a while to try to optimize our compiler "middle end".

  • Replace the atOwner idiom in Transformers with pushOwner / popOwner. Subclasses can customise these and stack context into ArrayBuffer. This will be allocation free, as opposed to the closures that currently need to be allocated to pass to atOwner.
  • Avoid the indirection through the bridges implied by api.Transformer to reduce the Java stack depth during transforms (making stack traces easier to read, cheaper to collect in profiles, and maybe more inlinable)

This might also lead to a way for us to have a lighter weight localTyper, without a full Typer/Context combo.

  • Verify correctness of the patch (partest --pos works so far)
  • Benchmark the change for compile speed and allocation rate
  • Look at the stack traces of the transform for user friendliness

The followup idea is the try to tag each Type and Tree subclass with an Int and replace our pattern matches on these with a @switch match.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions