danchia / ddb

Apache License 2.0
128 stars 28 forks source link

Help : Memtable #1

Closed devsohi closed 6 years ago

devsohi commented 6 years ago

@danchia I went through code for memtable . Just have few doubts

  1. is memtable lock free skiplist ?
  2. does memtable only support insert operation ?
danchia commented 6 years ago

The memtable is indeed a lock free skiplist, and it only supports inserts. Updates and deletes are achieved by inserting a new entry with the same key, but a fresher timestamp.

devsohi commented 6 years ago

@danchia Thanks for quick response . Just beginners doubt . (sorry for more questions)

  1. If memtable is lock free, then what is use mu.Lock as first statement in Insert function. Here Would not this lock entire method and insertion will become sequential for that memtable ?
danchia commented 6 years ago

Good questions - it's actually only lock-free on reading, not insertion. For very write-heavy workloads this may pose a problem, but I'm waiting for that to happen before worrying :)

devsohi commented 6 years ago

Cool. Looking forward to lock free implementation for write heavy workloads . (also more tutorials on ddb :-) )