Bug 545491 - Improved performance of ReferenceCollection

The implementation of reference collection suffered from a couple
of quadratic lookup operations in its logic to determine, whether
the collection includes certain names.

Instead of doing a simple nested loop scanning of the given arrays,
we apply an algorithm based on the reduced runtime complexity of
binary searches.

The reference collections are long living objects that are far more
often queried than modified. Now we use a simple comparator to sort the
arrays by length and content. When the collection is asked whether it
contains another list of names, these names have to be interned. In
addition to the interning, we also sort the argument arrays. Now we
do have a total of three pairs of arrays, each of the paired arrays is
sorted by the same criteria. That allows to walk both arrays pairways
so even if the worst case, we do no longer need O(n*m) with
n=first.length and m = second.length, but only O(2*(n+m)) comparisons.
For longer arrays, we even use binary search logic to skip more than
one array index when we advance the iteration.

In our scenario, this reduced the accumulated time for invocations of
include from 90s to less than one second.

Change-Id: Ib35b4250ab34fbab55723ebe1f9ad345afca86dd
Signed-off-by: Sebastian Zarnekow <sebastian.zarnekow@gmail.com>
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
5 files changed
tree: 8a08073584871130198024fc07c1d7a033190826
  1. modules/
  2. org.eclipse.jdt.annotation/
  3. org.eclipse.jdt.annotation_v1/
  4. org.eclipse.jdt.apt.core/
  5. org.eclipse.jdt.apt.pluggable.core/
  6. org.eclipse.jdt.apt.pluggable.tests/
  7. org.eclipse.jdt.apt.tests/
  8. org.eclipse.jdt.apt.ui/
  9. org.eclipse.jdt.compiler.apt/
  10. org.eclipse.jdt.compiler.apt.tests/
  11. org.eclipse.jdt.compiler.tool/
  12. org.eclipse.jdt.compiler.tool.tests/
  13. org.eclipse.jdt.core/
  14. org.eclipse.jdt.core.ecj.validation/
  15. org.eclipse.jdt.core.internal.tools/
  16. org.eclipse.jdt.core.tests.builder/
  17. org.eclipse.jdt.core.tests.compiler/
  18. org.eclipse.jdt.core.tests.model/
  19. org.eclipse.jdt.core.tests.performance/
  20. tests-pom/
  21. .gitignore
  22. CONTRIBUTING
  23. LICENSE
  24. NOTICE
  25. pom.xml
  26. README.md
README.md

JDT Core

This is the core part of Eclipse's Java development tools. It contains the non-UI support for compiling and working with Java code, including the following:

  • an incremental or batch Java compiler that can run standalone or as part of the Eclipse IDE
  • Java source and class file indexer and search infrastructure
  • a Java source code formatter
  • APIs for code assist, access to the AST and structured manipulation of Java source.

For more information and important links, refer to the [JDT wiki page] 1 or the [JDT project overview page] 2.

License

Eclipse Public License (EPL) v1.0