Hi, Just to explain better what I am worried about. The overall sum of counters in TOPN does not have very good meaning if you have more than N target.
Lets for simplicity assume that we have TOPN for N=1 (i.e. old code). It guarantees if target X is taken by more than 50% of times, it will win, however its count can be arbitrarily low. Consider following sequence of call targets Y Z Z Y Y Z Z X X X X X X X X X The TOPN counter will behave as follows: Y1 Y0 Z1 Z0 Y1 Y0 Z1 Z0 X1 X2 X3 X4 X5 X6 X7 X8 Now for sequence Y Y Y X X X Z Z Z X X X Z X X X Y1 Y2 Y3 Y2 Y1 Y0 Z1 Z2 Z3 Z2 Z1 Z0 Z1 Z0 X1 X2 There are 16 calls, 9 of them calling X, 3 calls of Y and 4 calls of Z. Depending on order the counter of X can be anywhere between 2 and 8. So setting threshold without trashing a lot of valid cases would be hard and if you have something like 40k of parallel invocations of clang I would expect quite high divergence between the runs. Similar sequence exists for N>1, you only need to populate other entries by new targets. However based on observation above we could probably scale up the probabilites assuming that the missing part of histogram has pretty much the same distribution as known part. Honza