PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
183 stars 48 forks source link

Performance got worse in the last 2 weeks #1127

Closed ghaith closed 1 month ago

ghaith commented 2 months ago

It might be the change with the parser errors, but I noticed that on big projects a lot of time would pass before we see the first error. We should investigate that.

volsa commented 2 months ago

Did some quick research and it looks like I have unlocked an achievement, unintentionally fucking up the performance by a lot due to https://github.com/PLC-lang/rusty/commit/94a74fd429b0e3da03e795e181342823fa402615. Specifically the find_local_member method internally calls find_enum_variant_in_pou which works on raw (sub)string comparisons. I knew it would have some performance penalties (especially because there's no caching for already performed queries) but I didn't think it would be this bad. Anyways, seems like we need to refactor how enums are stored in the index hence closely related to https://github.com/PLC-lang/rusty/issues/1112.

Picture of plc check ... profile, previously taking around 4 seconds on an internal project but now takes between 2 and 4 minutes

Screenshot 2024-03-11 at 10 42 59
volsa commented 2 months ago

Also https://plc-lang.github.io/metrics/ wasn't able to detect any performance regressions, we really need to find some big open source library which we can include in the metrics...