nakabonne/tstorage

Can I ask a question? why not lock in here. See the link below

keroro6 opened this issue · 4 comments

if head != nil {
node.next = head
}

Hi @keroro6, thank you for your interest.

I would say we don't have to lock there at all. You can check it by writing a tiny test code like:

func TestInsertRows(t *testing.T) {
	node := &partitionNode{
		val: &fakePartition{
			minT: 1,
		},
	}
	list := &partitionListImpl{
		numPartitions: 1,
		head:          node,
		tail:          node,
	}
	for i := 0; i < 10000; i++ {
		go list.insert(newMemoryPartition(nil, 0, ""))
	}
}

You can see any data race doesn't occur.

$ go test -race -v -run=TestInsertRows
=== RUN   TestInsertRows
--- PASS: TestInsertRows (0.26s)
PASS
ok      github.com/nakabonne/tstorage   0.550s

I'm opening to any questions.

Thanks for your reply. I will try. I'm interest to the project really

Glad to hear that. Ask me anything.

Let me close this. Feel free to re-open if you come up with an additional question.