From: Eric Wong Date: 2014-01-04T00:26:50+00:00 Subject: [ruby-core:59542] Re: [ruby-trunk - Feature #9362][Assigned] Minimize cache misshit to gain optimal speed Eric Wong wrote: > 3 bits for embedded array/struct length does not seem to be enough :< Six bits is enough for 32-bit and 64-byte cache line sizes. Hopefully not clobbering anything else that's important... Still building the rest (this is a slow VM). Fwiw, we should probably be clamping objects at 64-bytes for now in case cache lines get bigger. I no longer have access to any machine with 128-byte cache lines. --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -898,7 +898,8 @@ struct RArray { }; #define RARRAY_EMBED_FLAG FL_USER1 /* FL_USER2 is for ELTS_SHARED */ -#define RARRAY_EMBED_LEN_MASK (FL_USER6|FL_USER7|FL_USER8) +#define RARRAY_EMBED_LEN_MASK \ + (FL_USER6|FL_USER7|FL_USER8|FL_USER9|FL_USER10|FL_USER11) #define RARRAY_EMBED_LEN_SHIFT (FL_USHIFT+6) #define RARRAY_LEN(a) \ ((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \ @@ -1098,7 +1099,8 @@ struct RStruct { const VALUE ary[RSTRUCT_EMBED_LEN_MAX]; } as; }; -#define RSTRUCT_EMBED_LEN_MASK (FL_USER3|FL_USER2|FL_USER1) +#define RSTRUCT_EMBED_LEN_MASK \ + (FL_USER6|FL_USER5|FL_USER4|FL_USER3|FL_USER2|FL_USER1) #define RSTRUCT_EMBED_LEN_SHIFT (FL_USHIFT+1) #define RSTRUCT_LEN(st) \ ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \