anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

Code Cleanup slow #530

Closed dsaveyn closed 6 months ago

dsaveyn commented 7 months ago

Running the code cleanup for the active editor is since today (or somewhere last week) very slow. I takes a couple of minutes to cleanup a single file. In task manager the cpu usage consumed by AZ Al Dev Tools is 25% or higher.

We are using the settings below.

I tried disabling some settings but the slowness unfortunately remains.


    "alOutline.lockRemovedFieldsCaptions": true,
    "alOutline.addToolTipsToPageFields": true,
    "alOutline.codeCleanupActions": [
        "AddMissingParentheses",
        "AddObjectCaptions",
        "AddTableFieldCaptions",
        "AddToolTips",
        "AddPageFieldCaptions",
        "ConvertObjectIdsToNames",
        "FixIdentifiersCase",
        "FixKeywordsCase",
        "FormatDocument",
        "LockRemovedFieldCaptions",
        "RemoveBeginEnd",
        "RemoveUnusedVariables",
        "RemoveWithStatements",
        "SortPermissions",
        "SortPermissionSetList",
        "SortProperties",
        "SortVariables",
        "TrimTrailingWhitespace",
        "RemoveEmptyLines",
        "RemoveEmptySections",
        "RemoveEmptyTriggers",
        "RemoveRedundantAppAreas",
        "RemoveStrSubstNoFromError",
        "CollapseEmptyBrackets",
        "OneStatementPerLine", 
        "MakeFlowFieldsReadOnly", 
        "RemoveRedundantDataClassification",
        "AddEnumValuesCaptions"
    ],
    "alOutline.defaultAddPageFieldCaptionsSettings": {
        "setActionGroupsCaptions": true,
        "setActionsCaptions": true,
        "setLabelsCaptions": true,
        "setPartsCaptions": false
    },
    "alOutline.defaultRemoveUnusedVariablesSettings": {
        "removeGlobalVariables": true,
        "removeLocalMethodParameters": true,
        "removeLocalVariables": true
    },
    "alOutline.defaultRemoveEmptyTriggersSettings": {
        "removeTriggers": true,
        "removeSubscribers": true,
        "ignoreComments": true
    },```
fvet commented 7 months ago

I encounter the same experience. Running the code cleanup on the 'uncommit files' (6 staged files - few hundred lines of code) in a project of 100 files takes several minutes. Seems like the performance slowed down a lot the past weeks.

PS: As I work at the same company of @dsaveyn and if no other issues are reported, could it be linked to some of our intenal policies / antivirus settings?

anzwdev commented 7 months ago

Some of these commands need to recompile whole solution, which is much slower than simple transformation of a syntax tree created by parsing a single AL file. Could you try to remove these commands from CodeCleanup and check if it is still slow: "AddMissingParentheses", "ConvertObjectIdsToNames", "FixIdentifiersCase", "RemoveStrSubstNoFromError", "RemoveWithStatements",

dsaveyn commented 7 months ago

Both me and my colleague have tried disabling the commands above but unfortunately it doesn't really help.

Our command list specified in the settings file has not changed a lot in the last couple of months. So I tried different versions of the extension and I noticed versions 3.0.53 & 3.0.54 are noticeably faster. Things are starting to slow down from version 3.0.55 and onwards.

We also check task manager to make sure no other process (like a virus scanner) was messing around, but we can't see anything relevant.

anzwdev commented 6 months ago

Thank you for testing it. I was able to identify the area where code is much slower now, it will be fixed in the next release.

anzwdev commented 6 months ago

Thank you for reporting this issue. The problem was caused by namespaces handling in the extension. I've redesigned this area, it should work much faster now.

dsaveyn commented 6 months ago

I can confirm the cleanup is way faster now. Thank you very much, keep up the good work!