On Thu, Dec 11, 2025 at 4:36 PM Lidong Yan <[email protected]> wrote:
>
> Ian Lance Taylor <[email protected]> writes:
> >
> > I don't know all the details here, but scavChunkData packs into a
> > 64-bit value (see the pack method). That is useful because that 64-bit
> > value can be loaded and stored atomically. It works out that there are
> > only six bits available for scavChunkFlags, as the comment says. So a
> > 10-bit counter isn't available.
> >
> > Ian
>
> Thanks very much, but I also found the layout of scanChunkData is like:
> | 10-bit [inUse] + 6-bit unused  |  10-bit [lastInUse] + 6-bit 
> [scavChunkFlag]  |  32 bit [gen]  |
> And actually we have 12-bit left besides inUse/lastInUse/gen.
>
> ```go
> // pack returns sc packed into a uint64.
> func (sc scavChunkData) pack() uint64 {
>         return uint64(sc.inUse) |
>                 (uint64(sc.lastInUse) << 16) |
>                 (uint64(sc.scavChunkFlags) << (16 + logScavChunkInUseMax)) |
>                 (uint64(sc.gen) << 32)
> }
> ```

Thanks, I think you're right.

I suppose I'm not sure why a counter would help very much in practice.
The scenario in which it helps doesn't seem like a common one. But you
could try it and see if it helps with any benchmarks.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUBY5G-9SX4jNy7BMb%3DTNkpvZbb0%3DqVnvmsMgH6FCSxhw%40mail.gmail.com.

Reply via email to