dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

BatchSync() every 10 milliseconds ?

Open squalfof opened this issue 9 years ago • 5 comments

You've got 2 db instances: one for raft, the other for posting list. Since the Raft db help to prevent new data from losing, why not lower the frequency that BatchSync() is called on posting list db ? 10millisecond frequency may impact the performance, especially when running Dgraph on HDD.

squalfof avatar Apr 22 '17 13:04 squalfof

We can either make the frequency configurable. But i think we should check every 10ms atleast for any dirty pl's or they would get piled up in memory. If the frequency is high, stop the world would be triggered often and mutations are stalled during stop the world which is not good. Probably we should check every 10 millisecond and may be have an extra configurable parameter x, so that we would flush to disk only when we have x dirty pl's. Does that sound good ?

janardhan1993 avatar Apr 22 '17 15:04 janardhan1993

We already have a flag for that, called --gentlecommit. This is what configures how many dirty PLs get picked up to be synced to store. It's set to only 10% PLs per iteration. You can set it even lower, if you'd like.

Though, note that until the PLs make it to disk, our watermarks won't progress. Without explaining what a watermark is, they dictate how much data would need to be repopulated in case of a crash. The more PLs are synced, the more caught up would the watermark be, the lesser repopulation would need to be done in case of crash.

batchSync is just a single goroutine doing writes. It would have little relation with performance -- the main flag that you want to tweak is --gentlecommit. But, do note what @janardhan1993 mentioned -- if you use too much memory, which is typically the case during writes, you can make the overall performance worse by not syncing dirty PLs fast enough.

manishrjain avatar Apr 22 '17 20:04 manishrjain

Hi, agree with memory issue here.
My concern is by using HDD, each disk seek will occupy around 2ms. Once there is bunch of updates, Dgraph will first write to Raft WAL, then write to PL, then back to Raft WAL (Not quite sure if it works this way, correct me if I'm wrong). While you BatchSync() every 10ms, around half of the time will be wasted in the I/O seek, which may cause I/O bottleneck here ?

squalfof avatar May 01 '17 02:05 squalfof

The sequenece is:

  • Dgraph writes to Raft WAL

  • Once WAL is written and synced, the updates would be applied to PLs in memory.

  • Periodically gentle commit would set PLs to be written to disk. How many PLs would be picked up is decided by --gentlecommit flag.

  • BatchSync runs in a loop, so if one write takes more than X ms, the next iteration won't start until the previous one has finished.

Given these, I'm not sure about the I/O being a bottleneck per design.

manishrjain avatar May 01 '17 02:05 manishrjain

Closing this issue for now. Please bring it up on discuss.dgraph.io if needed.

manishrjain avatar May 05 '17 05:05 manishrjain