Fail fast in the matcher, let the debug outputs use the cache#1251
Conversation
tylerbenson
left a comment
There was a problem hiding this comment.
Looks reasonable... what kind of improvement did you see with this?
|
I'm still in progress on the changes. I'll put results in the description after |
0d010f0 to
af67dfa
Compare
| public class ReferenceMatcher implements WeakMap.ValueSupplier<ClassLoader, Boolean> { | ||
| private final WeakMap<ClassLoader, Boolean> mismatchCache = newWeakMap(); | ||
| private final Reference[] references; | ||
| private final Set<String> helperClassNames; |
There was a problem hiding this comment.
isn't this field always empty set ? where do we add elements to it ?
There was a problem hiding this comment.
Given that it is final, it must be assigned in the constructor.
There was a problem hiding this comment.
It is set to a list of the args in the constructor(s)
| * @return A list of mismatched sources. A list of size 0 means the reference matches the class. | ||
| */ | ||
| public static List<Reference.Mismatch> checkMatch(Reference reference, ClassLoader loader) { | ||
| public static List<Reference.Mismatch> checkMatch( |
|
I just noticed a downside to this change is the muzzle gradle task takes considerably longer, are we fine with that? |
In general, I think trading build time for runtime is a good idea. But I guess our runtime gain was rather small. Although, we'd probably see bigger gains on something where there are multiple versions instrumentations at play at the same time. |
I checked circle CI. The build was 11:40 instead of ~10ish. Not that big of a difference. The real fix is not checking all ~1000 versions for the amazon sdk |

Minimal CPU improvement unfortunately but does at least help some.
Memory stats should be treated as grain of salt. The test app results in 5:1 cache hit:miss ratio and 2 total mismatches (scala concurrent classes). So doesn't really exercise this cache.