Skip to content

Slow local variables load in VSCode due to inspect of large variables #674

@rockorequin

Description

@rockorequin

Your environment

  • ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
  • rdbg commit b8f799f from master

Describe the bug
VSCode is very slow to load the local variables window in my app when it stops at a breakpoint where the self object has an instance variable of type RubyXL::Worksheet (with images in it) as well as an instance variable for the parent workbook in the self because the obj.inspect in rdbg's safe_inspect is returning a very large string. See also #635 (comment) where the obj.inspect for a worksheet in the backtrace was taking nine or ten minutes to return a 16 MB string, and the comments at #635 (comment) and after.

I am running the debugger in a WSL instance, so this might be slowing things down more than running it natively.

Expected behavior
VSCode should be able to load the local variables window in a reasonable time (preferably micro or milliseconds) rather than freezing.

Additional context
One solution is to use the same fix as for #635 by using the LimitedPP.pp call instead of obj.inspect in safe_inspect, eg:

 def self.safe_inspect obj, max_length: SHORT_INSPECT_LENGTH, short: false
    if short
      LimitedPP.pp(obj, max_length)
    else
      #obj.inspect
      LimitedPP.pp(obj, 32768)
    end

With this change, the local variables window loads in VSCode in a reasonable time.

I tried using a limit of up to 128 kB and the local variables window is noticeably slow to load but still of the order of a second.

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