Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-6504

java code completion slow - poor algorithm choice

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 13
    • None
    • cnd - Code Completion
    • None
    • gentoo linux, slackware64-current.  btrfs and jfs.  openjdk18, 32GB RAM, 1TB NVME SSD PCI3x4.

      i do not believe this is related to the other bug reports of slow completion which seem to be platform specific (ntfs).

       

    • Patch

    Description

      I have a class with a mere 3000 constants and it takes a few hundred milliseconds to show and (it seems to run twice?) delete the completion popup when these constants are imported using a wildcard static import.  This makes editing extremely tedious and heavily drains a laptop battery.

      I tracked it down to ElementUtilities.isHidden() invoked from getLocalMembersAndVars() using an inefficient algorithm to filter results. Most of the time time is spent in in toString() via Name::compareContents().

      Perhaps there's a reason it isn't used in this case but addIfNotHidden() seems to have been written to address this performance issue but is only used in one of the methods which callls isHidden().

      I've attached a couple of patches.  One just changes getLocalMembersAndVars() to use addIfNotHidden(), the second is more complete and changes all uses of isHidden() to use addIfNotHidden() in a consistent way and also removes the redundant name comparison in the inner loop.

      I'm sorry, i'm not sure how to trigger all code paths to test the patches.

      Attachments

        1. slow-complete-simple.patch
          3 kB
          notzed
        2. slow-complete-full.patch
          13 kB
          notzed

        Activity

          People

            Unassigned Unassigned
            notzed notzed
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: