diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-10-14 18:39:08 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-10-14 18:39:08 +0000 |
commit | e58c74cdd0f93f00bf203e2cf71a19e176fd19a9 (patch) | |
tree | 644103207534bd2a0e0c0c6cc4f21b3805b21429 /src/fs | |
parent | 5fb1771f7ad557a57e9aaaf26369b646ed028f2a (diff) |
-optimizing all FS multi hashmaps for key memory sharing
git-svn-id: https://gnunet.org/svn/gnunet@24318 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 22 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 13 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 23 |
3 files changed, 43 insertions, 15 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 3de45ff483..916289dff4 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -315,6 +315,7 @@ static char *respectDirectory; */ static struct GNUNET_ATS_PerformanceHandle *ats; + /** * Get the filename under which we would store respect * for the given peer. @@ -617,7 +618,8 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, GNUNET_free (fn); cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_put (cp_map, + &GSF_connected_peer_get_identity2_ (cp)->hashPubKey, cp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), @@ -1646,7 +1648,7 @@ GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls) /** * Obtain the identity of a connected peer. * - * @param cp peer to reserve bandwidth from + * @param cp peer to get identity of * @param id identity to set (written to) */ void @@ -1659,6 +1661,20 @@ GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, /** + * Obtain the identity of a connected peer. + * + * @param cp peer to get identity of + * @return reference to peer identity, valid until peer disconnects (!) + */ +const struct GNUNET_PeerIdentity * +GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp) +{ + GNUNET_assert (0 != cp->ppd.pid); + return GNUNET_PEER_resolve2 (cp->ppd.pid); +} + + +/** * Assemble a migration stop message for transmission. * * @param cls the 'struct GSF_ConnectedPeer' to use @@ -1811,7 +1827,7 @@ cron_flush_respect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void GSF_connected_peer_init_ () { - cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); + cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 2d24b313cb..3bb05ace65 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h @@ -384,7 +384,7 @@ GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, /** * Obtain the identity of a connected peer. * - * @param cp peer to reserve bandwidth from + * @param cp peer to get identity of * @param id identity to set (written to) */ void @@ -393,6 +393,17 @@ GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, /** + * Obtain the identity of a connected peer. + * + * @param cp peer to get identity of + * @return reference to peer identity, valid until peer disconnects (!) + */ +const struct GNUNET_PeerIdentity * +GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp); + + + +/** * Iterate over all connected peers. * * @param it function to call for each peer diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index bc08eebe7f..6a82720de9 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -558,7 +558,7 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) void GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) { - struct GNUNET_PeerIdentity id; + const struct GNUNET_PeerIdentity *id; struct PeerPlan *pp; struct GSF_PendingRequestData *prd; struct GSF_RequestPlan *rp; @@ -567,18 +567,19 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) struct MergeContext mpc; GNUNET_assert (NULL != cp); - GSF_connected_peer_get_identity_ (cp, &id); - pp = GNUNET_CONTAINER_multihashmap_get (plans, &id.hashPubKey); + id = GSF_connected_peer_get_identity2_ (cp); + pp = GNUNET_CONTAINER_multihashmap_get (plans, &id->hashPubKey); if (NULL == pp) { pp = GNUNET_malloc (sizeof (struct PeerPlan)); - pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); + pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); pp->priority_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); pp->delay_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); pp->cp = cp; - GNUNET_CONTAINER_multihashmap_put (plans, &id.hashPubKey, pp, + GNUNET_CONTAINER_multihashmap_put (plans, + &id->hashPubKey, pp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } mpc.merged = GNUNET_NO; @@ -599,7 +600,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) prd = GSF_pending_request_get_data_ (pr); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Planning transmission of query `%s' to peer `%s'\n", - GNUNET_h2s (&prd->query), GNUNET_i2s (&id)); + GNUNET_h2s (&prd->query), GNUNET_i2s (id)); rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); // 8 MB rpr = GNUNET_malloc (sizeof (struct GSF_RequestPlanReference)); prl = GNUNET_malloc (sizeof (struct PendingRequestList)); @@ -627,18 +628,18 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) void GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) { - struct GNUNET_PeerIdentity id; + const struct GNUNET_PeerIdentity *id; struct PeerPlan *pp; struct GSF_RequestPlan *rp; struct GSF_PendingRequestData *prd; struct PendingRequestList *prl; - GSF_connected_peer_get_identity_ (cp, &id); - pp = GNUNET_CONTAINER_multihashmap_get (plans, &id.hashPubKey); + id = GSF_connected_peer_get_identity2_ (cp); + pp = GNUNET_CONTAINER_multihashmap_get (plans, &id->hashPubKey); if (NULL == pp) return; /* nothing was ever planned for this peer */ GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (plans, &id.hashPubKey, + GNUNET_CONTAINER_multihashmap_remove (plans, &id->hashPubKey, pp)); if (NULL != pp->pth) { @@ -760,7 +761,7 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) void GSF_plan_init () { - plans = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO); + plans = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_YES); } |