Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop sharing lock between write and read #21

Open
nakabonne opened this issue Jul 11, 2021 · 1 comment
Open

Stop sharing lock between write and read #21

nakabonne opened this issue Jul 11, 2021 · 1 comment

Comments

@nakabonne
Copy link
Owner

All data points are immutable, and all write operation is append-only. Logically any read operation and write operation don't conflict at all.

In spite of that, we currently lock with Mutex whenever reading and writing.

// TODO: Consider to stop using mutex every time.
// Instead, fix the capacity of points slice, kind of like:
/*
m.points := make([]*DataPoint, 1000)
for i := 0; i < 1000; i++ {
m.points[i] = point
}
*/
m.mu.Lock()
defer m.mu.Unlock()

@nakabonne nakabonne changed the title Stop locking for memory partition Stop sharing lock between write and read Jul 27, 2021
@nakabonne
Copy link
Owner Author

nakabonne commented Jul 27, 2021

Like MVCC (Multi Version Concurrency Control), it's enough to keep a read-only snapshot at a certain point and give back it when reading out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant