* btest2.c
@ 2009-11-14 23:10 Jeff Garzik
0 siblings, 0 replies; only message in thread
From: Jeff Garzik @ 2009-11-14 23:10 UTC (permalink / raw)
To: hail-devel
This is a simple test to determine memory usage for storing object
locations in RAM, indexed by node id, and optimized for
- rapid object id insertion, deletion
- easy method to determine all objects in a single node
Compile with
gcc -O -Wall `pkg-config glib-2.0 --cflags` -o btest2 btest2.c \
`pkg-config glib-2.0 --libs`
RAM usage with 10,000,000 objects, 3-way replication: 750 MB
RAM usage with 20,000,000 objects, 3-way replication: 1.5 GB
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <glib.h>
enum {
N_OBJS = 5 * 1000000,
N_NID = 3,
N_NODES = 1000,
};
static GHashTable *ht[N_NODES];
static void store_oid_in_node(int node, int oid)
{
g_hash_table_insert(ht[node], GINT_TO_POINTER(oid), NULL);
}
int main (int argc, char *argv[])
{
int oid, i, n_objs = 0;
long x = 1;
srand(time(NULL));
/* obtain number of objects for test */
if (argc > 1)
n_objs = atoi(argv[1]);
if (n_objs < 1)
n_objs = N_OBJS;
/* create N_NODES hash tables for oid indices */
for (i = 0; i < N_NODES; i++) {
ht[i] = g_hash_table_new(g_direct_hash, g_direct_equal);
if (!ht[i])
abort();
}
/* populate hash tables with N_NID-way simulated replication */
for (oid = 1; oid < n_objs; oid++)
for (i = 0; i < N_NID; i++) {
int node;
node = rand() % N_NODES;
store_oid_in_node(node, oid);
}
/*
* once this prints, you may visit top(1) to determine
* memory usage
*/
printf("Table build completed. Begin infinite loop...\n");
while (1)
x++;
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-14 23:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-14 23:10 btest2.c Jeff Garzik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.