This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Penalize non-instance members when accessed via class instances.
ClosedPublic

Authored by ioeric on Jul 19 2018, 6:23 AM.

Details

Summary

The following are metrics for explicit member access completions. There is no
noticeable impact on other completion types.

Before:
EXPLICIT_MEMBER_ACCESS

Total measurements: 24382
All measurements: MRR: 62.27	Top10: 80.21%	Top-100: 94.48%
Full identifiers: MRR: 98.81	Top10: 99.89%	Top-100: 99.95%
0-5 filter len:

MRR: 13.25 46.31 62.47 67.77 70.40 81.91
Top-10: 29% 74% 84% 91% 91% 97%
Top-100: 67% 99% 99% 99% 99% 100%

After:
EXPLICIT_MEMBER_ACCESS

Total measurements: 24382
All measurements: MRR: 63.18	Top10: 80.58%	Top-100: 95.07%
Full identifiers: MRR: 98.79	Top10: 99.89%	Top-100: 99.95%
0-5 filter len:

MRR: 13.84 48.39 63.55 68.83 71.28 82.64
Top-10: 30% 75% 84% 91% 91% 97%
Top-100: 70% 99% 99% 99% 99% 100%

  • Top-N: wanted result is found in the first N completion results.
  • MRR: Mean reciprocal rank.

Remark: the change seems to have minor positive impact. Although the improvement
is relatively small, down-ranking non-instance members in instance member access
should reduce noise in the completion results.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric created this revision.Jul 19 2018, 6:23 AM
sammccall accepted this revision.Jul 20 2018, 9:23 AM
sammccall added inline comments.
clangd/CodeComplete.h
148 ↗(On Diff #156253)

nit: "sema" is a bit down-in-the-weeds here, maybe just 'Context' or 'DetectedContext'?

148 ↗(On Diff #156253)

can you add an a test to CodeCompleteTests for this new API?

clangd/Quality.cpp
146 ↗(On Diff #156253)

I think we also have to consider template functions too?
And ideally I think we want to exclude constructors (but include destructors).

325 ↗(On Diff #156253)

could be even harsher here, but this is fine for now

clangd/Quality.h
102 ↗(On Diff #156253)

again, I'd drop "sema" here. It's not as though we can get several contexts from different sources.

This revision is now accepted and ready to land.Jul 20 2018, 9:23 AM
ioeric updated this revision to Diff 156738.Jul 23 2018, 3:54 AM
ioeric marked 4 inline comments as done.
  • addressed review comments.
This revision was automatically updated to reflect the committed changes.
ioeric added inline comments.Jul 23 2018, 4:34 AM
clangd/Quality.cpp
146 ↗(On Diff #156253)

Done for template functions.

I'm not very sure whether constructors are instance members in general, but they should already be filtered out by sema in dot/arror member accessed.