Skip to content

Merge recvs and waits into one uint64. #807

@rueian

Description

@rueian

We have two int32 counters in the pipe struct, recvs and waits, for tracking concurrent requests on the pipe.

waits will be increased when receiving a request and decreased when the request is finished.
recvs will be increased when a request is finished and never decreased.

For recvs, we don't care if it overflows because we don't care about its actual value but only check if it changes.
For waits, we know it will not overflow because it should stay close to 0.

Can we merge these counters into one uint64 to save atomic operations? For example:

recvs is the upper 32bits and waits is the lower 32bits.
when receiving a request, we increment the uint64 by 1.
when a request is finished, we decrement the uint64 by 1 + 1<<32.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions