lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> And I have a new idea :
>
> We can separate 32bit into two id space , one is 0~2^31 and another is -2^31~ -1 .
>
> At first , we use the positive part , and we choose smaller id after comparing. when the id exceed 2^31, we switch to negative part.
>
> At this time, we renumber the id in sweep stage of gc just by allocate a new negative id for each string alive.
>
> After renumber, the rule is changed to choose bigger id after comparing until we need to switch id space next time.
>
> 2^31 is a very large range, so we seldom renumber .
>

We don't need renumber all the strings in one gc cycle when switch id
space, because the id space is large enough. and we can use a small
cache
to remember the map of new/old id. So most of id after switching may
not need to recalculate.

-- 
http://blog.codingnow.com