Skip to main content

[Google Docs] Optimization - Versioning


Versioning

3 ways to implement versioning:

  1. Entire document snapshot
  2. Delta snapshot with 1st version
  3. Hybrid document snapshot with delta snapshot

1. Entire document snapshot

For entire document snapshot, we can store the entire document by periodically.

But it has some disadvantages:

  • ❌ require a lot of storage space.


2. Delta snapshot with 1st version

For delta snapshot with 1st version, we can store the entire document as the 1st version, and then store the delta snapshot for each operation.

The operation record is like this:

Rev no.UserOperationsTimestampDocument state
0N/AN/A2024-08-03 10:00
1CharlieINS "Hello" @02024-08-03 10:05"Hello"
2AliceINS " world" @52024-08-03 10:10"Hello world"
3BobINS "!" @112024-08-03 10:15"Hello world!"
4DonaldINS " Goodbye" @122024-08-05 09:00"Hello world! Goodbye"
5ErinINS " earth" @202024-08-05 09:10"Hello world! Goodbye earth"

Which is very small compared to the entire document snapshot.



But for better user experience, it can be merged into a fewer versions.

VersionTimeLast edited by
12024-08-03 10:15Charlie, Bob, Alice
22024-08-05 09:10Donald, Erin

But it has some disadvantages:

  • ❌ if the operation is a lot from 1st version, it might take lots of operations to see the latest version.

3. Hybrid document snapshot with delta snapshot

For hybrid document snapshot with delta snapshot, we can save snapshot periodically, and then save the delta snapshot from specific version.

Which makes:

  • ✅ the storage requirement is smaller than the entire document snapshot.
  • ✅ the load speed is faster than the delta snapshot with 1st version.





References