Memory Optimization

Revision en4, by twoslow, 2019-02-28 20:32:25

I have a tuple T, consisting of

  1. An integer id in range [1, 70 × 106]
  2. A double score1 in range [0.0, 1.0]
  3. A double score2 in range [0.0, 1.0]
  4. An integer x in range [0, 2]

What can be the most efficient way to store such tuple T =  < id, score1, score2, x >  given that only 5 digits after the decimal are sufficient for score1 and score2.


Currently, I am storing this tuple as a long which takes 8 bytes of memory. 27 bits for id, 17 bits for score1, 17 bits for score2 (considering values upto 5 decimal digits), and 2 bits for x, Overall 63 bits.

I'm trying to optimize the memory usage as there are millions of such tuples in an array. Also, If your way can store digits more than 5 decimal places, please tell me.

Is there a way, by which we can store the tuple T using float? given that if the tuple is hashed to float, I should be able to get back id, x accurately and score1, score2 without much errors.

Thanks for your time, have a nice day.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English twoslow 2019-02-28 23:23:37 24 Tiny change: 'sing float?** given ' -> 'sing float or some other data type?** given '
en4 English twoslow 2019-02-28 20:32:25 4
en3 English twoslow 2019-02-27 22:59:17 4
en2 English twoslow 2019-02-27 22:23:30 30 Tiny change: ' as a long. $24$ bit' -> ' as a long which takes 8 bytes of memory. $24$ bit'
en1 English twoslow 2019-02-27 22:21:56 1040 Initial revision (published)