ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.55k stars 736 forks source link

[Improvement]: Reduce runtime type checker overhead #42000

Open heshanpadmasiri opened 6 months ago

heshanpadmasiri commented 6 months ago

Description

We have identified the fallowing optimization from nBallerina to be ported to jBallerina

  1. Caching type check results
  2. Introducing simple type tags

1 should improve performance in cases such as foreach loops over lists where we repeated do the type check for the same type pair (since list iterator is implemented using java interop)

Under 2 each type/value in runtime will have a pair of bit sets (most likely implemented directly as long), all representing each basic type it cover entirely and some representing each basic type it cover partially. We should be able to use these to efficiently prune away easy type checks.

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

heshanpadmasiri commented 4 months ago

With #42111 we are now caching common repeated type calculations. Since we are reworking the runtime type checker under #40511 we'll revisit this after that change