[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion : Use unique string type instead of two (short and long)
- From: 云风 Cloud Wu <cloudwu@...>
- Date: Tue, 18 Jun 2019 10:34:43 +0800
> 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