summaryrefslogtreecommitdiffstats
path: root/done/Features/memory-usage.md
blob: 4e1a8a0fb111fb4586b34f944a194634096bbecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
object expiry tracking memroy usage
====================================

Bitrot daemon tracks objects for expiry in a data structure known
as "timer-wheel" (after which the object is signed). It's a well
known data structure for tracking million of objects of expiry.
Let's see the memory usage involved when tracking 1 million
objects (per brick).

Bitrot daemon uses "br_object" structure to hold information
needed for signing. An instance of this structure is allocated
for each object that needs to be signed.

                struct br_object {
                        xlator_t *this;
                
                        br_child_t *child;
                
                        void *data;
                        uuid_t gfid;
                        unsigned long signedversion;
                
                        struct list_head list;
                };

Timer-wheel requires an instance of the structure below per
object that needs to be tracked for expiry.

                struct gf_tw_timer_list {
                        void *data;
                        unsigned long expires;
                
                        /** callback routine */
                        void (*function)(struct gf_tw_timer_list *, void *, unsigned long);
                
                        struct list_head entry;
                };

Structure sizes:

-  sizeof (struct br_object): 64 bytes
-  sizeof (struct gf_tw_timer_list): 40 bytes

Together, these structures take up 104 bytes. To track all 1 million objects
at the same time, the amount of memory taken up would be:

** 1,000,000 * 104 bytes: ~100MB**

Not so bad, I think.