microsoft / pyright

Static Type Checker for Python
Other
13.04k stars 1.39k forks source link

Modified parse node definitions so they are all "monomorphic" (the sa… #8371

Closed erictraut closed 1 month ago

erictraut commented 1 month ago

…me fields with the same layout). This helps the V8 engine optimize performance.

github-actions[bot] commented 1 month ago

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

DanielRosenwasser commented 1 month ago

You mentioned elsewhere you weren't seeing quite the same speed improvement results as in https://github.com/microsoft/TypeScript/pull/58928. One thing to note is that @dragomirtitian actually made three broader changes in that PR, and managed to untangle them into 3 separate PRs:

According to https://github.com/microsoft/TypeScript/pull/58928#issuecomment-2216956874, the win in monomorphizing types was the best one.

From this PR, it looks like you mostly changed syntax nodes. If you're seeing a \~5% improvement on average that probably checks out, though there might be other factors at play here too.

erictraut commented 1 month ago

@DanielRosenwasser, thanks for the additional info. I didn't realize that the changes in typescript went beyond syntax nodes. Yes, I suspect that making the type objects monomorphic will have a bigger impact than the parse nodes. It's a heavier lift to make that change, but it could be worth it.