Esempio n. 1
0
func main() {
	host := flag.String("host", "localhost", "host:port string of database to connect to")
	dbname := flag.String("db", "iibench", "dbname")
	collname := flag.String("coll", "purchases_index", "collname")
	numCollections := flag.Int("numCollections", 100, "number of collections to create per db")
	numDBs := flag.Int("numDBs", 100, "number of DBs to create")

	// will hard code 3 indexes.
	flag.Parse()
	session, err := mgo.Dial(*host)
	if err != nil {
		log.Fatal("Error connecting to ", *host, ": ", err)
	}
	// so we are not in fire and forget
	session.SetSafe(&mgo.Safe{})
	defer session.Close()

	// these are dummy indexes. We are not inserting data
	// we just want to create files
	indexes := make([]mgo.Index, 3)
	indexes[0] = mgo.Index{Key: []string{"pr", "cid"}}
	indexes[1] = mgo.Index{Key: []string{"crid", "pr", "cid"}}
	indexes[2] = mgo.Index{Key: []string{"pr", "ts", "cid"}}

	for i := 0; i < *numDBs; i++ {
		currDB := fmt.Sprintf("%s_%d", *dbname, i)
		mongotools.MakeCollections(*collname, currDB, *numCollections, session, indexes)
	}
}
Esempio n. 2
0
func main() {
	// needed for making/accessing collections:
	host := flag.String("host", "localhost", "host:port string of database to connect to")
	dbname := "partitionStress"
	collname := "partitionStress"

	flag.Parse()

	session, err := mgo.Dial(*host)
	if err != nil {
		log.Fatal("Error connecting to ", *host, ": ", err)
	}
	// so we are not in fire and forget
	session.SetSafe(&mgo.Safe{})
	defer session.Close()

	indexes := make([]mgo.Index, 3)
	indexes[0] = mgo.Index{Key: []string{"pr", "cid"}}
	indexes[1] = mgo.Index{Key: []string{"crid", "pr", "cid"}}
	indexes[2] = mgo.Index{Key: []string{"pr", "ts", "cid"}}

	mongotools.MakeCollections(collname, dbname, 1, session, indexes)
	// at this point we have created the collection, now run the benchmark
	res := new(iibench.Result)
	numWriters := 8
	numQueryThreads := 16
	workers := make([]benchmark.WorkInfo, 0, numWriters+numQueryThreads)
	currCollectionString := mongotools.GetCollectionString(collname, 0)
	for i := 0; i < numWriters; i++ {
		copiedSession := session.Copy()
		defer copiedSession.Close()
		var gen = iibench.NewDocGenerator()
		gen.CharFieldLength = 100
		gen.NumCharFields = 0
		workers = append(workers, mongotools.NewInsertWork(gen, copiedSession.DB(dbname).C(currCollectionString), 0))
	}
	for i := 0; i < numQueryThreads; i++ {
		copiedSession := session.Copy()
		defer copiedSession.Close()
		workers = append(workers, iibench.NewQueryWork(copiedSession, dbname, currCollectionString))
	}
	{
		copiedSession := session.Copy()
		defer copiedSession.Close()
		var addPartitionItem = partition_stress.AddPartitionWork{copiedSession.DB(dbname), currCollectionString, time.Hour}
		workers = append(workers, benchmark.WorkInfo{addPartitionItem, 1, 1, 0})
	}
	{
		copiedSession := session.Copy()
		defer copiedSession.Close()
		var dropPartitionItem = partition_stress.DropPartitionWork{copiedSession.DB(dbname), currCollectionString, 7 * time.Hour}
		workers = append(workers, benchmark.WorkInfo{dropPartitionItem, 1, 1, 0})
	}
	// have this go for a looooooong time
	benchmark.Run(res, workers, time.Duration(1<<32)*time.Second)
}
Esempio n. 3
0
func main() {
	flag.Parse()

	numTPSPerThread := (*numMaxTPS) / (uint64(*numThreads))

	session, err := mgo.Dial(*host)
	if err != nil {
		log.Fatal("Error connecting to ", *host, ": ", err)
	}
	// so we are not in fire and forget
	session.SetSafe(&mgo.Safe{})
	defer session.Close()

	mongotools.VerifyNotCreating()
	// just verifies that collections exist
	mongotools.MakeCollections(*collname, *dbname, *numCollections, session, make([]mgo.Index, 0))

	info := SysbenchInfo{
		*oltpRangeSize,
		*oltpPointSelects,
		*oltpSimpleRanges,
		*oltpSumRanges,
		*oltpOrderRanges,
		*oltpDistinctRanges,
		*oltpIndexUpdates,
		*oltpNonIndexUpdates}
	workers := make([]benchmark.WorkInfo, 0, *numThreads)
	var i uint
	for i = 0; i < *numThreads; i++ {
		copiedSession := session.Copy()
		defer copiedSession.Close()
		// allows transactions to be run on this session
		copiedSession.SetMode(mgo.Strong, true)
		var currItem benchmark.Work = SysbenchTransaction{
			info,
			copiedSession,
			*dbname,
			*collname,
			rand.New(rand.NewSource(time.Now().UnixNano())),
			*numCollections,
			*readOnly,
			*numMaxInserts}
		var currInfo benchmark.WorkInfo = benchmark.WorkInfo{currItem, numTPSPerThread, 1, 0}
		workers = append(workers, currInfo)
	}
	res := new(SysbenchResult)
	fmt.Println("passing in ", *numSeconds)
	benchmark.Run(res, workers, time.Duration(*numSeconds)*time.Second)
}
Esempio n. 4
0
func main() {
	flag.Parse()

	if *numInsertsPerThread > 0 && (*numQueryThreads > 0 || *numSeconds > 0) {
		log.Fatal("Invalid values for numInsertsPerThread: ", *numInsertsPerThread, ", numQueryThreads: ", *numQueryThreads, ", numSeconds: ", *numSeconds)
	}

	session, err := mgo.Dial(*host)
	if err != nil {
		log.Fatal("Error connecting to ", *host, ": ", err)
	}
	// so we are not in fire and forget
	session.SetSafe(&mgo.Safe{})
	defer session.Close()

	indexes := make([]mgo.Index, 3)
	indexes[0] = mgo.Index{Key: []string{"pr", "cid"}}
	indexes[1] = mgo.Index{Key: []string{"crid", "pr", "cid"}}
	indexes[2] = mgo.Index{Key: []string{"pr", "ts", "cid"}}

	mongotools.MakeCollections(*collname, *dbname, *numCollections, session, indexes)
	// at this point we have created the collection, now run the benchmark
	res := new(iibench.Result)
	workers := make([]benchmark.WorkInfo, 0, *numWriters+*numQueryThreads)
	for i := 0; i < *numWriters; i++ {
		copiedSession := session.Copy()
		defer copiedSession.Close()
		var gen = iibench.NewDocGenerator()
		currCollectionString := mongotools.GetCollectionString(*collname, i%*numCollections)
		workers = append(workers, mongotools.NewInsertWork(gen, copiedSession.DB(*dbname).C(currCollectionString), *numInsertsPerThread))
	}
	for i := 0; i < *numQueryThreads; i++ {
		currCollectionString := mongotools.GetCollectionString(*collname, i%*numCollections)
		copiedSession := session.Copy()
		defer copiedSession.Close()
		workers = append(workers, iibench.NewQueryWork(copiedSession, *dbname, currCollectionString))
	}
	benchmark.Run(res, workers, time.Duration(*numSeconds)*time.Second)
}
Esempio n. 5
0
func main() {
	flag.Parse()
	if *numWriters > *numCollections {
		log.Fatal("numWriters should not be greater than numCollections")
	}

	session, err := mgo.Dial(*host)
	if err != nil {
		log.Fatal("Error connecting to ", *host, ": ", err)
	}
	// so we are not in fire and forget
	session.SetSafe(&mgo.Safe{})
	defer session.Close()

	indexes := make([]mgo.Index, 1)
	indexes[0] = mgo.Index{Key: []string{"k"}}

	mongotools.MakeCollections(*collname, *dbname, *numCollections, session, indexes)
	// at this point we have created the collection, now run the benchmark
	res := new(iibench.Result)
	workers := make([]benchmark.WorkInfo, 0, *numWriters)

	var writers []SysbenchWriter = make([]SysbenchWriter, *numWriters)
	for i := 0; i < *numCollections; i++ {
		copiedSession := session.Copy()
		defer copiedSession.Close()
		currCollectionString := mongotools.GetCollectionString(*collname, i)
		var gen *SysbenchDocGenerator = new(SysbenchDocGenerator)
		gen.RandSource = rand.New(rand.NewSource(time.Now().UnixNano()))
		var curr benchmark.WorkInfo = mongotools.NewInsertWork(gen, copiedSession.DB(*dbname).C(currCollectionString), *numInsertsPerCollection)
		writers[i%*numWriters].writers = append(writers[i%*numWriters].writers, curr)
	}
	for i := 0; i < *numWriters; i++ {
		var curr benchmark.WorkInfo = benchmark.WorkInfo{Work: writers[i]}
		curr.MaxOps = writers[i].writers[0].MaxOps
		workers = append(workers, curr)
	}
	benchmark.Run(res, workers, 0)
}