helium / helium-packet-router

Apache License 2.0
8 stars 5 forks source link

routing by packet lookup #257

Closed michaeldjeffrey closed 9 months ago

michaeldjeffrey commented 9 months ago

This PR changes the way packets get their routing determined, for the purpose of having more freedom in how we store SessionKey Filters.

The when of packets

The first time a packet is see, we take a lock on the phash and start finding if it's routable. Any packets that come in during that time will queue themselves. Once the routing is figured out, the initial packet, and all the queued packets are routed, and the routing information is put into ETS. Any packet coming along after routing has been determined will immediately retrieve it's routes.

Multi-buy is always checked.

But there's a lot of changes to SKF storage...

The last_used timestamp for an SKF is removed. Worst case scenario is the applicable SKF is at the end of an ETS table, but that lookup is only done one time per hash.

This means we can keep SKF unique by session_key, and delete in constant time.

Other things of note

michaeldjeffrey commented 9 months ago

The current largest DevAddr used has ~13.5k Session Key Filters.

Providing a packet that will never match any of the SKFs. (running with a single core locally).

Number of SKfs Worst case time
100 4ms
1,000 27ms
10,000 217ms
20,000 431ms
50,000 1027 ms
100,000 2048ms