Skip to content

Performance issue in removeReflection related to enumerating the project's symbolMapping #891

Closed
@igandrews

Description

@igandrews

I put some of this in the pull request for the fix but I'll re-enter it here.

I have a large project with lots of types and members marked as @hidden. The CommentPlugin stores these in its hidden array and then later will invoke the removeReflection for each. That method may then recursively call itself so it ends up getting invoked for more than the number of hidden items. This is expected. The problem though is that for each invocation the removeReflection completely enumerates the symbolMapping of the project. In my case I had around 35k hidden items. If you include the descendants the removeReflection was invoked around 300k times. So 300k times it completely enumerated the symbolMapping which in my case started with around 90k items.

The pull request that addresses this is here:
#890

While there are probably lots of ways to address this (e.g. maybe it shouldn't even be storing the reflection for a hidden item but instead should return null from createDeclaration like it would for external items) the cleanest way to address this specific problem without significant churn seemed to be to just adjust the removeReflection. So the PR moves the clean up of the symbolMapping to happen after all the hidden items have been cleaned up. Since the removeReflection was called recursively and so would have processed the symbolMapping for those descendants the removeReflection tracks the id's of the reflections it processes so when the removeReflections does clean up the symbolMapping it can process all the items removed.

I'd really appreciate it if this could be accepted as it's preventing me from using the npm packaged version of typedoc. If there's more I can provide please let me know. Thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions