Skip to content

NetSim: Better cleaning of orphaned messages#1788

Merged
islemaster merged 2 commits into
stagingfrom
netsim_limit_router_throughput
Mar 27, 2015
Merged

NetSim: Better cleaning of orphaned messages#1788
islemaster merged 2 commits into
stagingfrom
netsim_limit_router_throughput

Conversation

@islemaster

Copy link
Copy Markdown
Contributor

The change in NetSimRouterNode.prototype.localSimulationOwnsMessageRow_ sums up what's being done here.

Before I had this big ugly logic block for deciding whether the local simulation could process a message, which sometimes depended on opening up the binary payload and parsing out headers to see where it was ultimately going.

Facing the possibility of duplicating this logic in NetSimShardCleaner, I decided it was easier to add a simulatedBy metadata field to every message.

Benefits:

  • I think it's more obvious and readable.
  • The routing check (which may happen a lot) is slightly faster in auto-DNS mode.
  • It became really easy for the shard cleaner to find messages with a bad destination node OR a bad simulating node.

Unfortunates:

  • Static method NetSimMessage.send now takes six arguments: shard, fromNode, toNode, simulatedBy, payload and onComplete. You also have to understand enough to pick a simulating node any time you send a message. Fortunately, this only happens in three places, right now: Client sending a message, router forwarding a message, auto-DNS sending a response.
  • A little more data going over the wire to the message table, that can technically be derived from existing information; but it was starting to feel fragile.

See also updated tests, and a new block of tests for auto-DNS behavior that will break if the simulatedBy property is set incorrectly at any point in the process.

…ogic for deciding whether our local client controls a message. Also, clean up messages that aren't being simulated by anyone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to unify the logic so that the sender always simulates, or are there reasons to have the recipient continue to receive when there is no router, or is it just not worth the trouble to unify?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Who simulates" effectively means, "which client has permission to pull this message out of storage?" In a P2P situation, that must be the receiving client as the sender has no indication of whether the message has been read.

We could reverse the logic when a router is present, and have a client act as the router for all messages destined for their own node; that would allow the router to just pass-through the simulatedBy property for all messages it processes, but I'm afraid it would make other router features like limited bandwidth and router stats seem less accurate - since the router gets immediate local notification when the sender simulates, it can at least update its own logs and timings immediately, and put the network delay between the router and the recipient (matching the delay in the arrival of the router stats).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes great sense, thanks for the explanation.

@davidsbailey

Copy link
Copy Markdown
Member

LGTM. Good tests!

islemaster added a commit that referenced this pull request Mar 27, 2015
…hput

NetSim: Better cleaning of orphaned messages
@islemaster islemaster merged commit 3ec23d1 into staging Mar 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants