1

I need to generate database timestamps for MVCC Snapshot isolation. The typical method utilized:

"Transactional actions are implemented in SI-TM as follows. TM BEGIN: A logical snapshot for the transaction is generated by obtaining a unique timestamp using an atomic increment to the global timestamp counter."

The problem with using this approach in a system with hundreds of cores is that it doesn't scale. There is a hardware limit of 10M atomic increments per second on a contested memory location.

Any ideas?

Community
  • 1
  • 1
Malbrain
  • 83
  • 7

1 Answers1

0

Here are two simple ideas, and a paper reference:

1) Instead of incrementing the counter by 1, increment it by N, giving clients effectively a range of transaction identifiers [c, c+N). For instance, if N=5, and the initial value of the counter is 1, then clients A, B, and C would get the following:

A: [1, 2, 3, 4, 5]
B: [6, 7, 8, 9, 10]
C: [11, 12, 13, 14, 15]

While this reduces the pressure on the atomic counter, as we can see from this example some clients (like client C) will get a relatively high range of ids while others get lower ranges (client A), and this will lead to higher abort rates in the system.

2) Use ranges of interleaved transaction identifiers. This is like 1, but we've added a step variable, S. Here's a simple example: If N=5 and S=3, and the initial value of the counter is 1, then clients A B and C would get the following:

A: [1, 4, 7, 10, 13]
B: [2, 5, 8, 11, 14]
C: [3, 6, 9, 12, 15]

This seems to have solved the problem of 1, but consider client D:

D: [16, 19, 22, 25, 28]

Now we're back to the same problem that solution #1 had. Tricks must be played with this technique to "get it right".

3) An interesting, but more complex, decentralized way of assigning transaction IDs is described here:

Tu, Stephen, Wenting Zheng, Eddie Kohler, Barbara Liskov, and Samuel Madden. "Speedy transactions in multicore in-memory databases." In Proceedings of the Twenty-Fourth ACM Symposium on Operating Systems Principles, pp. 18-32. ACM, 2013.

Jonathan Ellithorpe
  • 564
  • 1
  • 4
  • 17