Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # SLOB.R version 0.6
- # BJP 2013 - Twitter @BrianPardy - http://pardydba.wordpress.com/
- # See http://wp.me/p2Jp2m-4i for more information
- #
- #
- # Assumes three possible SLOB test models: READS, REDO, WRITES
- # READS are readers-only
- # REDO and WRITES are writers only, differing in size of buffer_cache (small = REDO, large = WRITES)
- #
- # Reports PREADS in SLOB.R READS model
- # Reports REDO in SLOB.R REDO model
- # Reports PWRITES in SLOB.R WRITES model
- # Use SLOB.R meta-model READWRITE to report PREADS+PWRITES in WRITES model
- #
- # Setup:
- # Run SLOB as usual, with at least three runs for each variable tested for each model
- # Save awr.txt between runs in filename matching [something]-variable.writers.readers
- # Example: AWR-FCSAN-run1.8.0, AWR-FCSAN-run2.8.0 (...) AWR-FCSAN-run10.8.0
- # AWR-ISCSINAS-run1.8.0, AWR-ISCSINAS-run2.8.0 (...) AWR-ISCSINAS-run10.8.0
- # (In this case, the variables would be "FCSCAN" and "ISCSINAS", comparing fibrechannel SAN to NAS)
- # Run awr_info.sh from SLOB distribution against all AWR files at the end and save the output
- # Load awr_info.sh output into R with: SLOB <- loadSLOB("filename")
- #
- # Hints:
- # Best results achieved with more SLOB runs - myavg() drops high and low values per set, averages remaining
- #
- # Detailed example usage:
- # Testing SLOB read, redo and readwrite models 10 times each with 8, 16, and 32 sessions on EXT3 vs EXT4
- # Used a tablespace on EXT3 for EXT3 testing and a tablespace on EXT4 for EXT4 testing
- # Used redo logs on EXT3 for EXT3 REDO testing and redo logs on EXT4 for EXT4 REDO testing
- # Ran SLOB/misc/awr_info.sh on all awr.txt reports generated from these 60 SLOB runs
- # Saved awr_info.sh output as filename "awrinfo"
- #
- # (Start R)
- # > source("SLOB.R")
- # > SLOB <- loadSLOB("awrinfo")
- # > SLOB.sesscounts < c(8, 16, 32) # Specify the number of sessions used in tests
- # > SLOB.read.vars <- c('EXT3', 'EXT4') # Specify the variables for READ testing: EXT3 vs EXT4
- # > SLOB.redo.vars <- SLOB.read.vars # Same variables for REDO testing as for READ testing
- # > SLOB.readwrite.vars <- SLOB.read.vars # Same variables for READWRITEtesting as for READ testing
- # > SLOB.reads <- SLOBreads(SLOB, SLOB.reads.vars, SLOB.sesscounts)
- # > SLOB.redo <- SLOBredo(SLOB, SLOB.redo.vars, SLOB.sesscounts)
- # > SLOB.readwrite <- SLOBreadwrite(SLOB, SLOB.readwrite.vars, SLOB.sesscounts)
- ### Previous three lines populate SLOB.reads, SLOB.redo and SLOB.readwrite variables with AWR results
- ### You can then interrogate those variables by typing their names
- # > SLOB.reads
- # 8 16 32 Overall
- # XFS 27223.89 46248.05 61667.21 44886.22
- # EXT3 30076.77 49302.59 59113.00 46094.39
- #
- #
- # Usage variants for more detailed investigation. Consider this advanced usage.
- # Most people should just use SLOBreads(), SLOBredo() and SLOBreadwrite()
- #
- #
- # Get average REDO bytes for variable 'foo' across all sessions:
- # avg(SLOB, 'REDO', 'foo')
- # redoavg(SLOB, 'foo')
- #
- # Get average REDO bytes for variable 'foo' with 8 sessions:
- # avg(SLOB, 'REDO', 'foo', 8)
- # redoavg(SLOB, 'foo', 8)
- #
- # Get average PREADS (physical read) for variable 'foo' across all sessions:
- # avg(SLOB, 'READS', 'foo')
- # readavg(SLOB, 'foo')
- #
- # Get average PWRITES (physical writes) for variable 'foo' with 16 sessions:
- # avg(SLOB, 'WRITES', 'foo', 16)
- # writeavg(SLOB, 'foo', 16)
- #
- # Get sum of PREADS and PWRITES for variable 'foo' with 32 sessions:
- # avg(SLOB, 'READWRITE', 'foo', 32)
- # readwriteavg(SLOB, 'foo', 32)
- #
- # Get average REDO bytes for multiple variables ('foo' and 'bar') across all sessions:
- # sapply(c('foo', 'bar'), redoavg, dat=SLOB)
- # or for 16 sessions:
- # sapply(c('foo', 'bar'), redoavg, dat=SLOB, sessioncount=16)
- # alternate: sapply(c('foo', 'bar'), avg, dat=SLOB, sessioncount=16, model='READS')
- # (Note: This returns separate results for each variable, it does not combine and average them)
- #
- # Get sum of PREADS and PWRITES for multiple variables ('XFS' and 'EXT3') across 16 sessions:
- # sapply(c('XFS', 'EXT3'), avg, dat=SLOB, sessioncount=16, model='READWRITE')
- #
- # View the top waits in XFS READ model with 16 sessions:
- # waits(SLOB, str='XFS', model='READS', sessioncount=16)
- #
- # View all data for a particular model with a specific session count:
- # SLOB[intersect(REDO(SLOB), sessions(16, SLOB)),]
- #
- #
- getruns <- function(dat, model, str, sessioncount) {
- tmp <- intersect(grep(str, dat$FILE), eval(parse(text=paste(model, '(dat)', sep=''))))
- if(missing(sessioncount)) { return(tmp)}
- else { intersect(tmp, sessions(sessioncount, dat))}
- }
- loadSLOB <- function(filename) {
- read.table(file=filename, sep="|", header=TRUE)
- }
- # heuristically identify REDO model runs - if this sucks for you, comment it out
- # and uncomment the alternate REDO function below. It expects your filenames to include
- # the string '-REDO-' when testing REDO performance.
- REDO <- function(dat) {
- setdiff(which(dat$REDO/(dat$PWRITES*8192) > 2), READS(dat))
- }
- #REDO <- function(dat) {
- # grep('-REDO-', dat$FILE)
- #}
- WRITES <- function(dat) {
- setdiff(which(dat$WRITERS > 0), REDO(dat))
- }
- READS <- function(dat) {
- which(dat$READERS > 0)
- }
- READWRITE <- function(dat) {
- WRITES(dat)
- }
- sessions <- function(n, dat) {
- union(which(dat$WRITERS == n), which(dat$READERS == n))
- }
- myavg <- function(z) {
- mean(z[!z %in% c(min(z), max(z))])
- }
- getavg <- function(mode, dat) {
- myavg(eval(parse(text=paste('dat$', mode, sep=''))))
- }
- redoavg <- function(dat, ...) {
- getavg('REDO', dat[getruns(dat, 'REDO', ...),])
- }
- readavg <- function(dat, ...) {
- getavg('PREADS', dat[getruns(dat, 'READS', ...),])
- }
- writeavg <- function(dat, ...) {
- getavg('PWRITES', dat[getruns(dat, 'WRITES', ...),])
- }
- readwriteavg <- function(dat, ...) {
- getavg('PWRITES', dat[getruns(dat, 'WRITES', ...),]) + getavg('PREADS', dat[getruns(dat, 'WRITES', ...),])
- }
- avg <- function(dat, model, ...) {
- if(model=='REDO') {
- getavg('REDO', dat[getruns(dat, 'REDO', ...),])
- } else if(model=='READS') {
- getavg('PREADS', dat[getruns(dat, 'READS', ...),])
- } else if (model=='WRITES') {
- getavg('PWRITES', dat[getruns(dat, 'WRITES', ...),])
- } else if (model=='READWRITE') {
- getavg('PWRITES', dat[getruns(dat, 'WRITES', ...),]) + getavg('PREADS', dat[getruns(dat, 'WRITES', ...),])
- }
- }
- waits <- function(dat, ...) {
- as.character(dat[getruns(dat, ...), 'TOP.WAIT'])
- }
- testdata <- function(dat, model, str, ...) {
- if(model=='REDO') {
- sapply(str, avg, dat=dat, model='REDO', ...)
- } else if(model=='READS') {
- sapply(str, avg, dat=dat, model='READS', ...)
- } else if(model=='WRITES') {
- sapply(str, avg, dat=dat, model='WRITES', ...)
- } else if (model=='READWRITE') {
- sapply(str, avg, dat=dat, model='READWRITE', ...)
- }
- }
- readdata <- function(dat, str, ...) {
- sapply(str, avg, dat=dat, model='READS', ...)
- }
- redodata <- function(dat, str, ...) {
- sapply(str, avg, dat=dat, model='REDO', ...)
- }
- readwritedata <- function(dat, str, ...) {
- sapply(str, avg, dat=dat, model='READWRITE', ...)
- }
- SLOBreads <- function(dat, strs, sessioncounts) {
- z <- data.frame()
- for(i in sessioncounts) {
- z <- rbind(z, readdata(dat, strs, i))
- }
- z <- rbind(z, readdata(dat, strs))
- z <- t(z)
- colnames(z) <- c(sessioncounts, 'Overall')
- rownames(z) <- strs
- return(z)
- }
- SLOBredo <- function(dat, strs, sessioncounts) {
- z <- data.frame()
- for(i in sessioncounts) {
- z <- rbind(z, redodata(dat, strs, i))
- }
- z <- rbind(z, redodata(dat, strs))
- z <- t(z)
- colnames(z) <- c(sessioncounts, 'Overall')
- rownames(z) <- strs
- return(z)
- }
- SLOBreadwrite <- function(dat, strs, sessioncounts) {
- z <- data.frame()
- for(i in sessioncounts) {
- z <- rbind(z, readwritedata(dat, strs, i))
- }
- z <- rbind(z, readwritedata(dat, strs))
- z <- t(z)
- colnames(z) <- c(sessioncounts, 'Overall')
- rownames(z) <- strs
- return(z)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement