This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Tune down quality score for class constructors so that it's ranked after class types.
ClosedPublic

Authored by ioeric on Jul 23 2018, 5:29 AM.

Details

Summary

Currently, class constructors have the same score as the class types, and they
are often ranked before class types. This is often not desireable and can
be annoying when snippet is enabled and constructor signatures are added.

Metrics:

==================================================================================================
                                        OVERALL
==================================================================================================
  Total measurements: 111117 (+0)
  All measurements:
	MRR: 64.06 (+0.20)	Top-5: 75.73% (+0.14%)	Top-100: 93.71% (+0.01%)
  Full identifiers:
	MRR: 98.25 (+0.55)	Top-5: 99.04% (+0.03%)	Top-100: 99.16% (+0.00%)
  Filter length 0-5:
	MRR:      15.23 (+0.02)		50.50 (-0.02)		65.04 (+0.11)		70.75 (+0.19)		74.37 (+0.25)		79.43 (+0.32)
	Top-5:    40.90% (+0.03%)		74.52% (+0.03%)		87.23% (+0.15%)		91.68% (+0.08%)		93.68% (+0.14%)		95.87% (+0.12%)
	Top-100:  68.21% (+0.02%)		96.28% (+0.07%)		98.43% (+0.00%)		98.72% (+0.00%)		98.74% (+0.01%)		98.81% (+0.00%)
==================================================================================================
                                        DEFAULT
==================================================================================================
  Total measurements: 57535 (+0)
  All measurements:
	MRR: 58.07 (+0.37)	Top-5: 69.94% (+0.26%)	Top-100: 90.14% (+0.03%)
  Full identifiers:
	MRR: 97.13 (+1.05)	Top-5: 98.14% (+0.06%)	Top-100: 98.34% (+0.00%)
  Filter length 0-5:
	MRR:      13.91 (+0.00)		38.53 (+0.01)		55.58 (+0.21)		63.63 (+0.30)		69.23 (+0.47)		72.87 (+0.60)
	Top-5:    24.99% (+0.00%)		62.70% (+0.06%)		82.80% (+0.30%)		88.66% (+0.16%)		92.02% (+0.27%)		93.53% (+0.21%)
	Top-100:  51.56% (+0.05%)		93.19% (+0.13%)		97.30% (+0.00%)		97.81% (+0.00%)		97.85% (+0.01%)		97.79% (+0.00%)

Remark:

  • The full-id completions have +1.05 MRR improvement.
  • There is no noticeable impact on EXPLICIT_MEMBER_ACCESS and WANT_LOCAL.

Diff Detail

Event Timeline

ioeric created this revision.Jul 23 2018, 5:29 AM

Just a drive-by comment.

clangd/Quality.cpp
211

NIT: This does not seem to change the score, right? Maybe just the assignment or merge with the Unknown case?

ioeric added inline comments.Jul 23 2018, 5:40 AM
clangd/Quality.cpp
211

Previously, constructors are treated as Function and got 1.1 boost. Now it doesn't get a boost. Merging with Unknown might make sense too, but I wonder if we want to be more explicit. Happy to change.

sammccall accepted this revision.Jul 23 2018, 9:27 AM

No opinion on the boost style thing.

unittests/clangd/QualityTests.cpp
198

duplicates previous line

280

This looks like it duplicates part of the test below, and removes a sensible test for scopes on constructors?

This revision is now accepted and ready to land.Jul 23 2018, 9:27 AM
ioeric updated this revision to Diff 156973.Jul 24 2018, 12:53 AM
ioeric marked 2 inline comments as done.
  • revert unintended changes.
ioeric added inline comments.Jul 24 2018, 12:55 AM
unittests/clangd/QualityTests.cpp
280

Oops, this was an accidental change...

ilya-biryukov added inline comments.Jul 24 2018, 1:30 AM
clangd/Quality.cpp
211

Have no statement for a no-op instead of "multiply by 1.0" seems clearer.
Other than that, no preferences on my side.

ioeric updated this revision to Diff 156980.Jul 24 2018, 1:51 AM
ioeric marked an inline comment as done.
  • Make constructor boost no-op.
This revision was automatically updated to reflect the committed changes.