Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

P2P find() optimization #1090

Closed
jmjatlanta opened this issue Jun 25, 2018 · 0 comments
Closed

P2P find() optimization #1090

jmjatlanta opened this issue Jun 25, 2018 · 0 comments
Labels
2d Developing Status indicating currently designing and developing a solution 4b Normal Priority Priority indicating the moderate impact to system/user -OR- existing workaround is costly to perform 6 P2P Impact flag identifying the peer-to-peer (P2P) layer 6 Performance Impacts flag identifying system/user efficiency, performance, etc. 9b Small Effort estimation indicating TBD performance

Comments

@jmjatlanta
Copy link
Contributor

Please see

for (const item_id& item_to_advertise : inventory_to_advertise)
{
if (peer->inventory_advertised_to_peer.find(item_to_advertise) != peer->inventory_advertised_to_peer.end() )
idump((*peer->inventory_advertised_to_peer.find(item_to_advertise)));
if (peer->inventory_peer_advertised_to_us.find(item_to_advertise) != peer->inventory_peer_advertised_to_us.end() )
idump((*peer->inventory_peer_advertised_to_us.find(item_to_advertise)));
if (peer->inventory_advertised_to_peer.find(item_to_advertise) == peer->inventory_advertised_to_peer.end() &&
peer->inventory_peer_advertised_to_us.find(item_to_advertise) == peer->inventory_peer_advertised_to_us.end())
{
items_to_advertise_by_type[item_to_advertise.item_type].push_back(item_to_advertise.item_hash);
peer->inventory_advertised_to_peer.insert(peer_connection::timestamped_item_id(item_to_advertise, fc::time_point::now()));
++total_items_to_send_to_this_peer;
if (item_to_advertise.item_type == trx_message_type)
testnetlog("advertising transaction ${id} to peer ${endpoint}", ("id", item_to_advertise.item_hash)("endpoint", peer->get_remote_endpoint()));
dlog("advertising item ${id} to peer ${endpoint}", ("id", item_to_advertise.item_hash)("endpoint", peer->get_remote_endpoint()));
}

It appears that the find() on these 2 collections are being called 3 times each, while 1 should suffice.

@jmjatlanta jmjatlanta added performance 2d Developing Status indicating currently designing and developing a solution 4b Normal Priority Priority indicating the moderate impact to system/user -OR- existing workaround is costly to perform 6 P2P Impact flag identifying the peer-to-peer (P2P) layer 6 Performance Impacts flag identifying system/user efficiency, performance, etc. 9b Small Effort estimation indicating TBD labels Jun 25, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
2d Developing Status indicating currently designing and developing a solution 4b Normal Priority Priority indicating the moderate impact to system/user -OR- existing workaround is costly to perform 6 P2P Impact flag identifying the peer-to-peer (P2P) layer 6 Performance Impacts flag identifying system/user efficiency, performance, etc. 9b Small Effort estimation indicating TBD performance
Projects
None yet
Development

No branches or pull requests

2 participants