mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
For counting we were using a table keyed on a struct containing Node pointers. For connections between ordinary nodes this works just fine. But for connections to/from the Internet node we want to track individual address/port combinations, which involves an extra lookup. Since our data structures generally contain values, not pointers, this produces aliases. As a result n connections from/to a node to/from a specific Internet IP+port would result in n rows in the count table, each with a count of 1, instead of one row with a count of n. Things wouldn't be so bad if it was actually rendered like that - annoying, but at least accurate - but... Each row has an ID which is computed from the node IDs and ports. Not Node references. The ID must be unique - the frontend will only render *one* thing per ID. Since the row IDs of our n rows are all the same, we see one row with a count of 1 instead of n rows with a count of 1. Furthermore, since the frontend's table row limiting is counting rows, not unique row IDs, a) fewer rows would be rendered than expected, and b) the displayed count of the number of extra rows would be too high. The fix is to replace the Node pointers in the key with Node IDs. This does require an extra table lookup when we come to produce the rows, but that is just a fairly cheap map lookup. Fixes #1495.