Documentation ¶
Index ¶
- Constants
- Variables
- func CollectCounts(coord *Coordinator, stats []int64) (int64, time.Duration, time.Duration, time.Duration, time.Duration, ...)
- func CollectOne(w *Worker) int64
- func GetTxns(bidrate float64) []float64
- func IsRead(t int) bool
- func PrintLockCounts(s *Store)
- func PrintStats(out string, stats []int64, f *os.File, coord *Coordinator, s *Store, nb int)
- func RandN(seed *uint32, n uint32) uint32
- func Randstr(sz int) string
- func StddevChunks(nc []int64) (int64, float64)
- func StddevKeys(nc []int64) (int64, float64)
- func UndoCKey(k Key) (uint64, rune)
- func Validate(c *Coordinator, s *Store, nkeys int, nproducts int, val []int32, n int) bool
- func WriteChunkStats(s *Store, f *os.File)
- func WriteCountKeyStats(coord *Coordinator, nb int, f *os.File)
- type BRecord
- func (br *BRecord) AddOneToRecord(e Entry)
- func (br *BRecord) Apply(val Value)
- func (br *BRecord) IsUnlocked() (bool, uint64)
- func (br *BRecord) Lock() (bool, uint64)
- func (br *BRecord) Own(last uint64) bool
- func (br *BRecord) SLock()
- func (br *BRecord) SRLock()
- func (br *BRecord) SRUnlock()
- func (br *BRecord) SUnlock()
- func (br *BRecord) Unlock(tid TID)
- func (br *BRecord) Value() Value
- func (br *BRecord) Verify(last uint64) bool
- type Bid
- type BuyNow
- type Candidates
- func (c *Candidates) Conflict(k Key, br *BRecord, op KeyType)
- func (c *Candidates) Merge(c2 *Candidates)
- func (c *Candidates) Print()
- func (c *Candidates) Read(k Key, br *BRecord)
- func (c *Candidates) ReadWrite(k Key, br *BRecord)
- func (c *Candidates) Stash(k Key)
- func (c *Candidates) Write(k Key, br *BRecord, op KeyType)
- type Chunk
- type Comment
- type Coordinator
- type ETransaction
- type Entry
- type Exp2
- type Item
- type Key
- func BidKey(id uint64) Key
- func BidsPerItemKey(item uint64) Key
- func BuyNowKey(item uint64) Key
- func CKey(x uint64, ch rune) Key
- func CommentKey(item uint64) Key
- func ItemKey(item uint64) Key
- func ItemsByCatKey(item uint64) Key
- func ItemsByRegKey(region uint64, categ uint64) Key
- func MaxBidBidderKey(item uint64) Key
- func MaxBidKey(item uint64) Key
- func NicknameKey(bidder uint64) Key
- func NumBidsKey(item uint64) Key
- func PairBidKey(bidder uint64, product uint64) Key
- func PairKey(x uint32, y uint32, ch rune) Key
- func ProductKey(product int) Key
- func RatingKey(user uint64) Key
- func SKey(s string) Key
- func TKey(x uint64, y uint64) Key
- func UserKey(bidder uint64) Key
- type KeyGenFunc
- type KeyType
- type LTransaction
- func (tx *LTransaction) Abort() TID
- func (tx *LTransaction) Commit() TID
- func (tx *LTransaction) GetPhase() int
- func (tx *LTransaction) MaybeWrite(k Key)
- func (tx *LTransaction) NoCount()
- func (tx *LTransaction) Read(k Key) (*BRecord, error)
- func (tx *LTransaction) RelinquishKey(n uint64, r rune)
- func (tx *LTransaction) Reset()
- func (tx *LTransaction) SetPhase(p int)
- func (tx *LTransaction) Store() *Store
- func (tx *LTransaction) UID(f rune) uint64
- func (tx *LTransaction) Worker() *Worker
- func (tx *LTransaction) Write(k Key, v Value, op KeyType)
- func (tx *LTransaction) WriteInt32(k Key, a int32, op KeyType) error
- func (tx *LTransaction) WriteList(k Key, l Entry, op KeyType) error
- func (tx *LTransaction) WriteOO(k Key, a int32, v Value, op KeyType) error
- type LocalStore
- type OTransaction
- func (tx *OTransaction) Abort() TID
- func (tx *OTransaction) Commit() TID
- func (tx *OTransaction) GetPhase() int
- func (tx *OTransaction) MaybeWrite(k Key)
- func (tx *OTransaction) NoCount()
- func (tx *OTransaction) Read(k Key) (*BRecord, error)
- func (tx *OTransaction) RelinquishKey(n uint64, r rune)
- func (tx *OTransaction) Reset()
- func (tx *OTransaction) SetPhase(p int)
- func (tx *OTransaction) Store() *Store
- func (tx *OTransaction) UID(f rune) uint64
- func (tx *OTransaction) Worker() *Worker
- func (tx *OTransaction) Write(k Key, v Value, op KeyType)
- func (tx *OTransaction) WriteInt32(k Key, a int32, op KeyType) error
- func (tx *OTransaction) WriteList(k Key, l Entry, op KeyType) error
- func (tx *OTransaction) WriteOO(k Key, a int32, v Value, op KeyType) error
- type OneStat
- type Overwrite
- type Query
- type ReadKey
- type Rec
- type Result
- func AtomicIncr(t Query, tx ETransaction) (*Result, error)
- func BigIncrTxn(t Query, tx ETransaction) (*Result, error)
- func BigRWTxn(t Query, tx ETransaction) (*Result, error)
- func BuyAndReadTxn(t Query, tx ETransaction) (*Result, error)
- func BuyTxn(t Query, tx ETransaction) (*Result, error)
- func IncrTxn(t Query, tx ETransaction) (*Result, error)
- func NewItemTxn(t Query, tx ETransaction) (*Result, error)
- func PutBidTxn(t Query, tx ETransaction) (*Result, error)
- func PutCommentTxn(t Query, tx ETransaction) (*Result, error)
- func ReadOneTxn(t Query, tx ETransaction) (*Result, error)
- func ReadTxn(t Query, tx ETransaction) (*Result, error)
- func RegisterUserTxn(t Query, tx ETransaction) (*Result, error)
- func SearchItemsCategTxn(t Query, tx ETransaction) (*Result, error)
- func SearchItemsRegionTxn(t Query, tx ETransaction) (*Result, error)
- func StoreBidTxn(t Query, tx ETransaction) (*Result, error)
- func StoreBuyNowTxn(t Query, tx ETransaction) (*Result, error)
- func StoreCommentTxn(t Query, tx ETransaction) (*Result, error)
- func ViewBidHistoryTxn(t Query, tx ETransaction) (*Result, error)
- func ViewItemTxn(t Query, tx ETransaction) (*Result, error)
- func ViewUserInfoTxn(t Query, tx ETransaction) (*Result, error)
- type RetryHeap
- type StatsHeap
- type Store
- func (s *Store) CreateKey(k Key, v Value, kt KeyType) *BRecord
- func (s *Store) CreateLockedKey(k Key, kt KeyType) (*BRecord, error)
- func (s *Store) CreateMuLockedKey(k Key, kt KeyType) (*BRecord, error)
- func (s *Store) CreateMuRLockedKey(k Key, kt KeyType) (*BRecord, error)
- func (s *Store) DD() map[Key]bool
- func (s *Store) Get(k Key) (*BRecord, error)
- func (s *Store) IsDD(k Key) bool
- func (s *Store) PrecomputeHashCode(k Key)
- func (s *Store) Set(br *BRecord, v Value, op KeyType)
- func (s *Store) SetInt32(br *BRecord, v int32, op KeyType)
- func (s *Store) SetList(br *BRecord, ve Entry, op KeyType)
- func (s *Store) SetOO(br *BRecord, a int32, v Value, op KeyType)
- type TID
- type TStore
- type TransactionFunc
- type User
- type Value
- type Worker
- func (w *Worker) Finished()
- func (w *Worker) GiveBack(n uint64, r rune)
- func (w *Worker) NextKey(f rune) uint64
- func (w *Worker) One(t Query) (*Result, error)
- func (w *Worker) PreallocateRubis(nx, nb, start int)
- func (w *Worker) Register(fn int, transaction TransactionFunc)
- func (w *Worker) Store() *Store
- type WriteKey
- type Zipf
Constants ¶
const ( NUM_USERS = 1000000 NUM_CATEGORIES = 20 NUM_REGIONS = 62 NUM_ITEMS = 533000 BIDS_PER_ITEM = 10 NUM_COMMENTS = 506000 BUY_NOW = .1 * NUM_ITEMS FEEDBACK = .95 * NUM_ITEMS )
const ( BUMP_EPOCH_MS = 80 EPOCH_INCR = 1 << 32 TXID_MASK = 0x00000000ffffffff CLEAR_TID = 0xffffffff00000000 )
const ( SPLIT = iota MERGE JOIN )
Phases
const ( SUM = iota MAX WRITE LIST OOWRITE )
const ( DOPPEL = iota OCC LOCKING )
const ( BUFFER = 100000 START_SIZE = 1000000 TIMES = 10 )
const ( // Transactions D_BUY = iota D_BUY_AND_READ D_READ_ONE D_READ_TWO D_INCR_ONE D_ATOMIC_INCR_ONE RUBIS_BID // 6 7% RUBIS_VIEWBIDHIST // 7 3% RUBIS_BUYNOW // 8 3% RUBIS_COMMENT // 9 1% RUBIS_NEWITEM // 10 4% RUBIS_PUTBID // 11 10% RUBIS_PUTCOMMENT // 12 1% RUBIS_REGISTER // 13 4% RUBIS_SEARCHCAT // 14 27% RUBIS_SEARCHREG // 15 12% RUBIS_VIEW // 16 23% RUBIS_VIEWUSER // 17 4% BIG_INCR BIG_RW LAST_TXN // Stats NABORTS NENOKEY NSTASHED NENORETRY NSAMPLES NGETKEYCALLS NDDWRITES NO_LOCK NFAIL_VERIFY NLOCKED NDIDSTASHED NREADABORTS LAST_STAT )
const (
CHUNKS = 256
)
const (
DEFAULT_LIST_SIZE = 10
)
Variables ¶
var ( ENOKEY = errors.New("doppel: no key") EABORT = errors.New("doppel: abort") ESTASH = errors.New("doppel: stash") ENORETRY = errors.New("app error: no retry") EEXISTS = errors.New("doppel: trying to create key which already exists") )
var Allocate = flag.Bool("allocate", true, "Allocate results")
var AlwaysSplit = flag.Bool("split", false, "Split every piece of data\n")
var ConflictWeight = flag.Float64("cw", 2.0, "Weight given to conflicts over writes\n")
var Conflicts = flag.Bool("conflicts", false, "Measure conflicts\n")
var CountKeys = flag.Bool("ck", false, "Count keys accessed")
var GStore = flag.Bool("gstore", false, "Use Gotomic Hash Map instead of Go maps\n")
var Latency = flag.Bool("latency", false, "Measure latency")
var NextEpoch int64
var Nfast int64
var NoConflictType = flag.Int("noconflict", -1, "Type of operation NOT to record conflicts on")
var PhaseLength = flag.Int("phase", 20, "Phase length in milliseconds, default 20")
var RMoved int64
var ReadWeight = flag.Float64("rw", 0.5, "Weight given to reads over stashes\n")
var SampleRate = flag.Int64("sr", 500, "Sample every sr transactions\n")
var Spinlock = flag.Bool("spinlock", false, "Use spinlocks for 2PL\n")
var SysType = flag.Int("sys", DOPPEL, "Type of system to run\n")
var Time_in_IE time.Duration
var Time_in_IE1 time.Duration
var TriggerCount = flag.Int("trigger", 100000, "How long the queue can get before triggering a phase change\n")
var UseRLocks = flag.Bool("rlock", true, "Use Rlocks\n")
var Version = flag.Int("v", 0, "Version counter to help distinguish runs\n")
var WMoved int64
var WRRatio = flag.Float64("wr", 2.0, "Ratio of sampled write conflicts and sampled writes to sampled reads at which to move a piece of data to split. Default 3")
Functions ¶
func CollectCounts ¶
func CollectOne ¶
func PrintLockCounts ¶
func PrintLockCounts(s *Store)
func PrintStats ¶
func StddevChunks ¶
func StddevKeys ¶
func WriteChunkStats ¶
func WriteCountKeyStats ¶
func WriteCountKeyStats(coord *Coordinator, nb int, f *os.File)
Types ¶
type BRecord ¶
type BRecord struct {
// contains filtered or unexported fields
}
func (*BRecord) AddOneToRecord ¶
func (*BRecord) IsUnlocked ¶
type Candidates ¶
type Candidates struct {
// contains filtered or unexported fields
}
m is very big; it should have every key the worker sampled. h is a heap of all keys we deemed interesting enough to add to the heap. This includes keys where the ratio is high enough to consider moving the key to dd, but also keys that are already dd. We add their statistics changes to the heap to be merged in on the next stats computation.
Since we limit what we add to h, it doesn't really have to be a heap. But one could imagine eliminating m and only looking at the top set of things in the heap instead.
func (*Candidates) Merge ¶
func (c *Candidates) Merge(c2 *Candidates)
func (*Candidates) Print ¶
func (c *Candidates) Print()
func (*Candidates) Read ¶
func (c *Candidates) Read(k Key, br *BRecord)
func (*Candidates) ReadWrite ¶
func (c *Candidates) ReadWrite(k Key, br *BRecord)
func (*Candidates) Stash ¶
func (c *Candidates) Stash(k Key)
type Coordinator ¶
type Coordinator struct { Workers []*Worker Coordinate bool PotentialPhaseChanges int64 Done chan chan bool Accelerate chan bool StartTime time.Time Finished []bool TotalCoordTime time.Duration GoTime time.Duration ReadTime time.Duration MergeTime time.Duration // contains filtered or unexported fields }
func NewCoordinator ¶
func NewCoordinator(n int, s *Store) *Coordinator
func (*Coordinator) Finish ¶
func (c *Coordinator) Finish()
func (*Coordinator) GetEpoch ¶
func (c *Coordinator) GetEpoch() TID
func (*Coordinator) IncrementEpoch ¶
func (c *Coordinator) IncrementEpoch(force bool)
func (*Coordinator) Latency ¶
func (c *Coordinator) Latency() (string, string)
func (*Coordinator) NextGlobalTID ¶
func (c *Coordinator) NextGlobalTID() TID
func (*Coordinator) Process ¶
func (c *Coordinator) Process()
type ETransaction ¶
type ETransaction interface { Reset() Read(k Key) (*BRecord, error) WriteInt32(k Key, a int32, op KeyType) error WriteList(k Key, l Entry, op KeyType) error WriteOO(k Key, a int32, v Value, op KeyType) error Write(k Key, v Value, op KeyType) Abort() TID Commit() TID SetPhase(int) GetPhase() int Store() *Store Worker() *Worker // Tell 2PL I am going to read and potentially write this key. // This is because I don't know how to upgrade locks. MaybeWrite(k Key) // Tell Doppel not to count this transaction's reads and writes // when deciding if records should be split. NoCount() // Get a unique key; give it up UID(rune) uint64 RelinquishKey(uint64, rune) }
type Key ¶
type Key [16]byte
func BidsPerItemKey ¶
func CommentKey ¶
func ItemsByCatKey ¶
func ItemsByRegKey ¶
func MaxBidBidderKey ¶
func NicknameKey ¶
func NumBidsKey ¶
func PairBidKey ¶
func ProductKey ¶
type KeyGenFunc ¶
type LTransaction ¶
type LTransaction struct {
// contains filtered or unexported fields
}
Not threadsafe. Tracks execution of transaction.
func StartLTransaction ¶
func StartLTransaction(w *Worker) *LTransaction
func (*LTransaction) Abort ¶
func (tx *LTransaction) Abort() TID
func (*LTransaction) Commit ¶
func (tx *LTransaction) Commit() TID
func (*LTransaction) GetPhase ¶
func (tx *LTransaction) GetPhase() int
func (*LTransaction) MaybeWrite ¶
func (tx *LTransaction) MaybeWrite(k Key)
This is when I am reading a key and I might write it later; acquire the write lock *before* the read.
func (*LTransaction) NoCount ¶
func (tx *LTransaction) NoCount()
func (*LTransaction) RelinquishKey ¶
func (tx *LTransaction) RelinquishKey(n uint64, r rune)
func (*LTransaction) Reset ¶
func (tx *LTransaction) Reset()
func (*LTransaction) SetPhase ¶
func (tx *LTransaction) SetPhase(p int)
func (*LTransaction) Store ¶
func (tx *LTransaction) Store() *Store
func (*LTransaction) UID ¶
func (tx *LTransaction) UID(f rune) uint64
func (*LTransaction) Worker ¶
func (tx *LTransaction) Worker() *Worker
func (*LTransaction) WriteInt32 ¶
func (tx *LTransaction) WriteInt32(k Key, a int32, op KeyType) error
type LocalStore ¶
type LocalStore struct { Ncopy int64 // contains filtered or unexported fields }
func NewLocalStore ¶
func NewLocalStore(s *Store) *LocalStore
func (*LocalStore) Apply ¶
func (ls *LocalStore) Apply(key Key, key_type KeyType, v Value, op KeyType)
func (*LocalStore) ApplyInt32 ¶
func (ls *LocalStore) ApplyInt32(key Key, key_type KeyType, a int32, op KeyType)
func (*LocalStore) ApplyList ¶
func (ls *LocalStore) ApplyList(key Key, entry Entry)
func (*LocalStore) Merge ¶
func (ls *LocalStore) Merge()
type OTransaction ¶
type OTransaction struct {
// contains filtered or unexported fields
}
Tracks execution of transaction.
func StartOTransaction ¶
func StartOTransaction(w *Worker) *OTransaction
func (*OTransaction) Abort ¶
func (tx *OTransaction) Abort() TID
func (*OTransaction) Commit ¶
func (tx *OTransaction) Commit() TID
func (*OTransaction) GetPhase ¶
func (tx *OTransaction) GetPhase() int
func (*OTransaction) MaybeWrite ¶
func (tx *OTransaction) MaybeWrite(k Key)
func (*OTransaction) NoCount ¶
func (tx *OTransaction) NoCount()
func (*OTransaction) RelinquishKey ¶
func (tx *OTransaction) RelinquishKey(n uint64, r rune)
func (*OTransaction) Reset ¶
func (tx *OTransaction) Reset()
func (*OTransaction) SetPhase ¶
func (tx *OTransaction) SetPhase(p int)
func (*OTransaction) Store ¶
func (tx *OTransaction) Store() *Store
func (*OTransaction) UID ¶
func (tx *OTransaction) UID(f rune) uint64
func (*OTransaction) Worker ¶
func (tx *OTransaction) Worker() *Worker
func (*OTransaction) WriteInt32 ¶
func (tx *OTransaction) WriteInt32(k Key, a int32, op KeyType) error
type Query ¶
type Query struct { TXN int W chan struct { R *Result E error } T TID K1 Key K2 Key A int32 U1 uint64 U2 uint64 U3 uint64 U4 uint64 U5 uint64 U6 uint64 U7 uint64 S1 string S2 string I int TS time.Time S time.Time }
I tried keeping a slice of interfaces; the reflection was costly. Hard code in random parameter types to re-use for now.
type Result ¶
type Result struct {
V Value
}
func AtomicIncr ¶
func AtomicIncr(t Query, tx ETransaction) (*Result, error)
This is special. It does not use the Commit() protocol, instead it just performs atomic increments on keys. It is impossible to abort, and no stats are kept to indicate this key should be in split phase or not. This shouldn't be run in a mix with any other transaction types.
func BigIncrTxn ¶
func BigIncrTxn(t Query, tx ETransaction) (*Result, error)
func BigRWTxn ¶
func BigRWTxn(t Query, tx ETransaction) (*Result, error)
Version of Big that puts keys in read set (doesn't rely on commutativity)
func BuyAndReadTxn ¶
func BuyAndReadTxn(t Query, tx ETransaction) (*Result, error)
func NewItemTxn ¶
func NewItemTxn(t Query, tx ETransaction) (*Result, error)
func PutCommentTxn ¶
func PutCommentTxn(t Query, tx ETransaction) (*Result, error)
func ReadOneTxn ¶
func ReadOneTxn(t Query, tx ETransaction) (*Result, error)
func RegisterUserTxn ¶
func RegisterUserTxn(t Query, tx ETransaction) (*Result, error)
func SearchItemsCategTxn ¶
func SearchItemsCategTxn(t Query, tx ETransaction) (*Result, error)
func SearchItemsRegionTxn ¶
func SearchItemsRegionTxn(t Query, tx ETransaction) (*Result, error)
func StoreBidTxn ¶
func StoreBidTxn(t Query, tx ETransaction) (*Result, error)
TODO: Check and see if I need more tx.MaybeWrite()s
func StoreBuyNowTxn ¶
func StoreBuyNowTxn(t Query, tx ETransaction) (*Result, error)
func StoreCommentTxn ¶
func StoreCommentTxn(t Query, tx ETransaction) (*Result, error)
func ViewBidHistoryTxn ¶
func ViewBidHistoryTxn(t Query, tx ETransaction) (*Result, error)
func ViewItemTxn ¶
func ViewItemTxn(t Query, tx ETransaction) (*Result, error)
func ViewUserInfoTxn ¶
func ViewUserInfoTxn(t Query, tx ETransaction) (*Result, error)
type Store ¶
type Store struct { NChunksAccessed []int64 // contains filtered or unexported fields }
Global data
func (*Store) CreateLockedKey ¶
func (*Store) CreateMuLockedKey ¶
func (*Store) CreateMuRLockedKey ¶
func (*Store) PrecomputeHashCode ¶
type TransactionFunc ¶
type TransactionFunc func(Query, ETransaction) (*Result, error)
type Worker ¶
type Worker struct { sync.RWMutex ID int E ETransaction // Stats Nstats []int64 Nwait time.Duration Nmerge time.Duration Nmergewait time.Duration Njoin time.Duration Njoinwait time.Duration Nnoticed time.Duration NKeyAccesses []int64 // Rubis junk LastKey []int CurrKey []int PreAllocated bool // contains filtered or unexported fields }
func (*Worker) PreallocateRubis ¶
func (*Worker) Register ¶
func (w *Worker) Register(fn int, transaction TransactionFunc)
type WriteKey ¶
type WriteKey struct {
// contains filtered or unexported fields
}
TODO: Handle writing more than once to a key in one transaction