[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24215 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24215 - gnunet/src/fs |
Date: |
Sun, 7 Oct 2012 19:56:31 +0200 |
Author: grothoff
Date: 2012-10-07 19:56:31 +0200 (Sun, 07 Oct 2012)
New Revision: 24215
Modified:
gnunet/src/fs/gnunet-service-fs_pe.c
gnunet/src/fs/gnunet-service-fs_pr.c
gnunet/src/fs/gnunet-service-fs_pr.h
Log:
-reducing memory use for PendingRequestData by 30% by not allocating space for
target/namespace hash codes unless the request needs/has them
Modified: gnunet/src/fs/gnunet-service-fs_pe.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pe.c 2012-10-07 13:41:40 UTC (rev
24214)
+++ gnunet/src/fs/gnunet-service-fs_pe.c 2012-10-07 17:56:31 UTC (rev
24215)
@@ -585,7 +585,7 @@
mpc.pr = pr;
GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map,
&GSF_pending_request_get_data_
- (pr)->query, &merge_pr, &mpc);
+ (pr)->query, &merge_pr, &mpc);
// 8 MB in 'merge_pr'
if (mpc.merged != GNUNET_NO)
return;
GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map,
@@ -600,7 +600,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Planning transmission of query `%s' to peer `%s'\n",
GNUNET_h2s (&prd->query), GNUNET_i2s (&id));
- rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan));
+ rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); // 8 MB
rpr = GNUNET_malloc (sizeof (struct GSF_RequestPlanReference));
prl = GNUNET_malloc (sizeof (struct PendingRequestList));
rpr->rp = rp;
@@ -613,8 +613,8 @@
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (pp->plan_map,
get_rp_key (rp), rp,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
- plan (pp, rp);
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); // 8 MB
+ plan (pp, rp); // +5 MB (plan/heap-insert)
}
Modified: gnunet/src/fs/gnunet-service-fs_pr.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.c 2012-10-07 13:41:40 UTC (rev
24214)
+++ gnunet/src/fs/gnunet-service-fs_pr.c 2012-10-07 17:56:31 UTC (rev
24215)
@@ -277,6 +277,8 @@
{
struct GSF_PendingRequest *pr;
struct GSF_PendingRequest *dpr;
+ size_t extra;
+ struct GNUNET_HashCode *eptr;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating request handle for `%s' of type %d\n",
@@ -284,19 +286,27 @@
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop ("# Pending requests created"), 1,
GNUNET_NO);
- pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest));
+ extra = 0;
+ if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
+ extra += sizeof (struct GNUNET_HashCode);
+ if (NULL != target)
+ extra += sizeof (struct GNUNET_PeerIdentity);
+ pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest) + extra);
pr->local_result_offset =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
pr->public_data.query = *query;
+ eptr = (struct GNUNET_HashCode *) &pr[1];
if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
{
- GNUNET_assert (NULL != namespace);
- pr->public_data.namespace = *namespace;
+ GNUNET_assert (NULL != namespace);
+ pr->public_data.namespace = eptr;
+ memcpy (eptr, namespace, sizeof (struct GNUNET_HashCode));
+ eptr++;
}
if (NULL != target)
{
- pr->public_data.target = *target;
- pr->public_data.has_target = GNUNET_YES;
+ pr->public_data.target = (struct GNUNET_PeerIdentity *) eptr;
+ memcpy (eptr, target, sizeof (struct GNUNET_PeerIdentity));
}
pr->public_data.anonymity_level = anonymity_level;
pr->public_data.priority = priority;
@@ -401,7 +411,8 @@
sizeof (struct GNUNET_HashCode))) ||
((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) &&
(0 !=
- memcmp (&pra->public_data.namespace, &prb->public_data.namespace,
+ memcmp (pra->public_data.namespace,
+ prb->public_data.namespace,
sizeof (struct GNUNET_HashCode)))))
return GNUNET_NO;
return GNUNET_OK;
@@ -509,7 +520,7 @@
bm |= GET_MESSAGE_BIT_SKS_NAMESPACE;
k++;
}
- if (GNUNET_YES == pr->public_data.has_target)
+ if (NULL != pr->public_data.target)
{
bm |= GET_MESSAGE_BIT_TRANSMIT_TO;
k++;
@@ -545,9 +556,11 @@
GNUNET_PEER_resolve (pr->sender_pid,
(struct GNUNET_PeerIdentity *) &ext[k++]);
if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
- memcpy (&ext[k++], &pr->public_data.namespace, sizeof (struct
GNUNET_HashCode));
- if (GNUNET_YES == pr->public_data.has_target)
- ext[k++] = pr->public_data.target.hashPubKey;
+ memcpy (&ext[k++], pr->public_data.namespace, sizeof (struct
GNUNET_HashCode));
+ if (NULL != pr->public_data.target)
+ memcpy (&ext[k++],
+ pr->public_data.target,
+ sizeof (struct GNUNET_PeerIdentity));
if (pr->bf != NULL)
GNUNET_assert (GNUNET_SYSERR !=
GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf,
@@ -782,7 +795,7 @@
GNUNET_NO);
prq->eval =
GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf,
pr->mingle,
- &pr->public_data.namespace,
+ pr->public_data.namespace,
(prq->type ==
GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
sizeof (struct GNUNET_HashCode) : 0, prq->data,
@@ -1073,7 +1086,7 @@
if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
{
xquery = buf;
- memcpy (buf, &pr->public_data.namespace, sizeof (struct GNUNET_HashCode));
+ memcpy (buf, pr->public_data.namespace, sizeof (struct GNUNET_HashCode));
xquery_size = sizeof (struct GNUNET_HashCode);
}
if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY))
Modified: gnunet/src/fs/gnunet-service-fs_pr.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.h 2012-10-07 13:41:40 UTC (rev
24214)
+++ gnunet/src/fs/gnunet-service-fs_pr.h 2012-10-07 17:56:31 UTC (rev
24215)
@@ -88,14 +88,16 @@
/**
* Namespace to query, only set if the type is SBLOCK.
+ * Allocated after struct only if needed. Do not free!
*/
- struct GNUNET_HashCode namespace;
+ const struct GNUNET_HashCode *namespace;
/**
* Identity of a peer hosting the content, only set if
* 'has_target' is GNUNET_YES.
+ * Allocated after struct only if needed. Do not free!
*/
- struct GNUNET_PeerIdentity target;
+ const struct GNUNET_PeerIdentity *target;
/**
* Fields for the plan module to track a DLL with the request.
@@ -164,11 +166,6 @@
unsigned int results_found;
/**
- * Is the 'target' value set to a valid peer identity?
- */
- int has_target;
-
- /**
* Has this request been started yet (local/p2p operations)? Or are
* we still constructing it?
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24215 - gnunet/src/fs,
gnunet <=