cppalliance / NuDB

NuDB: A fast key/value insert-only database for SSD drives in C++11
Boost Software License 1.0
384 stars 59 forks source link

Is single-threaded operation deterministic? #49

Closed MarkusTeufelberger closed 7 years ago

MarkusTeufelberger commented 7 years ago

As far as I understand the design, if there are a lot of writes happening, buckets might overflow and log files might be written until the pressure goes down a bit.

However, if only one single thread writes to a database, with all elements in a certain order at insertion time is there a guarantee that the database file(s) will be bitwise identical (if the same salt/pepper is used) or might there be other effects in play that might cause indeterministic behaviour?

vinniefalco commented 7 years ago

In theory yes if only one thread performs insertions, then the resulting key and data files should be the same no matter the size of NuDB's internal batches.

MarkusTeufelberger commented 7 years ago

Perfect, thanks. :-)

vinniefalco commented 7 years ago

However, its not guaranteed behavior. In other words, don't write production code that depends on this, because it could change in a future version.

MarkusTeufelberger commented 7 years ago

Okay, my main idea was to deterministically create a database that can directly get imported by rippled. If this is not guaranteed behaviour but only a current implementation detail, then it might make more sense to have a more stable data representation (e.g. JSON) for storing data and import the data into the actual import database later in an extra step.