Estimate bridge users by country based on requests by country, if
available, to get more accurate numbers than those obtained from
unique IP address counts.
Fixes#18167.
Estimate relay users by country based on responses to directory
requests to reduce the overall effect of binning and to make relay and
bridge user estimates more comparable.
Implements #18203.
The old PL/pgSQL version of this function made three lookups in the
bwhist table to 1) check whether a row already exists, 2) insert or
update the row, and 3) update the row once again with array sums. The
new SQL version uses the INSERT ON CONFLICT statement introduced in
PostgreSQL 9.5 (Debian stretch has 9.6, buster has 11). The
performance gain measured using metrics-test is impressive, computed
aggregates are equivalent.
This change extends the ipv6servers module to generate all relevant
data about servers (relays and bridges) that the legacy module
currently generates.
There are several reasons why this is useful:
- This change is a step towards implementing all statistics in Java,
without needing to call psql or other external tools from within
Ant. In fact, it's a step towards getting rid of Ant for executing
modules.
- The ipv6servers module already supports other statistics than
absolute server counts, namely advertised bandwidths. It's easy to
extend statistics to consensus weights and guard/middle/exit
probabilities. This prepares future graphs which can be added
quite easily.
- With these new statistics we can finally provide graphs on bridges
by version or platform. Or we can extend current graphs to display
both relays and bridges, if we want to avoid adding more graphs.
This commit does not yet remove any code from the legacy module. That
will be the next logical step. It will even be fun.
Implements #28116.