cbaenzig at mines.edu
2007-Jul-10 01:38 UTC
[Rd] Plot dies with memory not mapped (segfault) (PR#9785)
Full_Name: Clay B Version: 2.5.0 (2007-04-23) OS: Solaris Nevada Build 55b Submission from: (NULL) (65.101.229.198) I find that running this script causes R to segfault reliably. However, running just for one system at a time (modifying the for loop updating iter to run just for a system at a time works). The system is a Sun W2100z with 12 GB of ram, and R segfaults using only around 360 MB of ram. I can include MySQL output fed to the script on request, but it's usually for failure data around a max of 1,000 data points in the "failureQuery", and less than 30,000 for "usageQuery". I can generate a core if desired too. ------------------------ begin traceback ------------------------------------------ s> source("SysVUserTime.R") Loading required package: DBI *** caught segfault *** address f9, cause 'memory not mapped' Traceback: 1: axis(side = side, at = at, labels = labels, ...) 2: Axis.default(...) 3: Axis(...) 4: localAxis(x, side = 1, ...) 5: plot.default(g$fit, g$res, xlab = "Fitted", ylab = "Residuals") 6: plot(g$fit, g$res, xlab = "Fitted", ylab = "Residuals") 7: eval.with.vis(expr, envir, enclos) 8: eval.with.vis(ei, envir) 9: source("SysVUserTime.R") Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: 3 ------------------------- end traceback ------------------------------------------- ------------------------ begin script --------------------------------------------- #Connects to database library(RMySQL) library(chron) CLAY_CLASS<-TRUE PIE_CHARTS<-FALSE BOXPLOTS<-TRUE PLOTTING<-TRUE OUTPUT_TEXT<-FALSE ACF_PLOT<-TRUE query_dates<-c("Year","Quarter","Month","Week") oldpar <- par(no.readonly = TRUE) drv <- dbDriver("MySQL") con <- dbConnect(drv, user="macs370",dbname="lanl",password="macs370") systems<-c("s8_usage_clean","s15_usage_clean","s16_usage_clean","s23_usage_clean","s20_usage_node_num_cpu") systemNum<-c("8","15","16","23","20") # Query for each system for (iter in 1:length(systems)) { #for (iter in 5:5) { rm(dat,res,IQR_Stats,userStatTimes,cors,data) if(OUTPUT_TEXT!=TRUE) { sink(paste("/export/MACS370_project/Image/SysVUserTime/CorrelationsSys",systemNum[iter],".TXT",sep="")) } if(PIE_CHARTS==TRUE) { for (iter in 1:length(systems)) { X11() res<- dbSendQuery(con, paste("SELECT SUM(cpu_seconds_user)/SUM(total_time), SUM(cpu_seconds_system)/SUM(total_time) FROM ",systems[iter],";",sep="")) dat<- fetch(res,n=-1) data<-rbind(dat[,1],dat[,2]) pie(data,labels=c("User","System"),main=paste("System vs. User Time for System ",systemNum[iter],"by",QUERY_DATE,sep="")) } } # Query for each date segmentation for(k in 1:length(query_dates)) { #for(k in 4:4) { #for(k in 2:2) { QUERY_DATE<-query_dates[k] userTime<-NULL failures<-NULL # Date Clamp Limits Us To The Middle 80% Of All Data usageDateClamp<-paste(" WHERE FROM_UNIXTIME(submit_time) >= (SELECT ", "FROM_UNIXTIME(MIN(submit_time)) + INTERVAL 0.10*", "DATEDIFF(MAX(FROM_UNIXTIME(submit_time)),MIN(FROM_UNIXTIME(", "submit_time))) DAY FROM ",systems[iter],") AND FROM_UNIXTIME(", "submit_time) <= (SELECT FROM_UNIXTIME(MAX(submit_time)) - ", "INTERVAL 0.10*DATEDIFF(MAX(FROM_UNIXTIME(submit_time)),MIN(", "FROM_UNIXTIME(submit_time))) DAY FROM ",systems[iter],") ", sep="") failureDateClamp<-paste(" AND prob_start_date >= (SELECT ", "FROM_UNIXTIME(MIN(submit_time)) + INTERVAL 0.10*", "DATEDIFF(MAX(FROM_UNIXTIME(submit_time)),MIN(FROM_UNIXTIME(", "submit_time))) DAY FROM ",systems[iter],") ", "AND prob_start_date <= (SELECT ", "FROM_UNIXTIME(MAX(submit_time)) - INTERVAL 0.10*", "DATEDIFF(MAX(FROM_UNIXTIME(submit_time)),MIN(FROM_UNIXTIME(", "submit_time))) DAY FROM ",systems[iter],") ",sep="") if(QUERY_DATE=="Year") { usageAVGQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d') AS date, AVG(cpu_seconds_user/total_time) AS time, AVG(num_cpus) AS AVG_CPUs, AVG(dispatch_time-end_time) AS AVG_job_length FROM ",systems[iter],usageDateClamp,"GROUP BY date;",sep="") usageQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d') AS date, cpu_seconds_user/total_time AS time FROM ",systems[iter]," ",usageDateClamp,";",sep="") if(CLAY_CLASS=="TRUE") { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(clay_class='Interconnect' OR clay_class='Disk' OR clay_class='Memory' OR clay_class='Networking, Machine Access' OR clay_class='Shared Storage',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-01-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d');",sep="") } else { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(hw_desc!='',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-01-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-01-01'),'%Y-%m-%d');",sep="") } } else if(QUERY_DATE=="Quarter") { usageAVGQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d') AS date, AVG(cpu_seconds_user/total_time) AS time, AVG(num_cpus) AS AVG_CPUs, AVG(dispatch_time-end_time) AS AVG_job_length FROM ",systems[iter],usageDateClamp,"GROUP BY date;",sep="") usageQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d') AS date, cpu_seconds_user/total_time AS time FROM ",systems[iter],usageDateClamp,";",sep="") # failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(clay_class='Interconnect' OR clay_class='Disk' OR clay_class='Memory' OR clay_class='Networking, Machine Access' OR clay_class='Shared Storage',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-',QUARTER(prob_start_date)*3,'-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d');",sep="") failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(hw_desc!='',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-',QUARTER(prob_start_date)*3,'-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',QUARTER(FROM_UNIXTIME(dispatch_time))*3,'-01'),'%Y-%m-%d');",sep="") } else if(QUERY_DATE=="Month") { usageAVGQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d') AS date, AVG(cpu_seconds_user/total_time) AS time, AVG(num_cpus) AS AVG_CPUs, AVG(dispatch_time-end_time) AS AVG_job_length FROM ",systems[iter],usageDateClamp," GROUP BY date;",sep="") usageQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d') AS date, cpu_seconds_user/total_time AS time FROM ",systems[iter],usageDateClamp,";",sep="") if(CLAY_CLASS=="TRUE") { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(clay_class='Interconnect' OR clay_class='Disk' OR clay_class='Memory' OR clay_class='Networking, Machine Access' OR clay_class='Shared Storage',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-',MONTH(prob_start_date),'-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d');",sep="") } else { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(hw_desc!='',1,0)) AS probs, STR_TO_DATE(CONCAT(YEAR(prob_start_date),'-',MONTH(prob_start_date),'-01'),'%Y-%m-%d') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEAR(FROM_UNIXTIME(dispatch_time)),'-',MONTH(FROM_UNIXTIME(dispatch_time)),'-01'),'%Y-%m-%d');",sep="") } } else if(QUERY_DATE=="Week") { usageAVGQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'), '%X%V %W') AS date, AVG(cpu_seconds_user/total_time) AS time, AVG(num_cpus) AS AVG_CPUs, AVG(dispatch_time-end_time) AS AVG_job_length FROM ",systems[iter],usageDateClamp," GROUP BY date;",sep="") usageQuery<-paste("SELECT STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'), '%X%V %W') AS date, cpu_seconds_user/total_time AS time FROM ",systems[iter],usageDateClamp,";",sep="") # failureQuery<- paste("SELECT STR_TO_DATE(CONCAT(YEARWEEK(prob_start_date), ' Monday'),'%X%V %W') as date, count(*)/(SELECT count(*) FROM failure_data WHERE system=",systemNum[iter],failureDateClamp,") AS probs FROM failure_data WHERE system=",systemNum[iter]," AND hw_desc!='' GROUP BY date;",sep="") if(CLAY_CLASS=="TRUE") { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'),'%X%V %W')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(clay_class='Interconnect' OR clay_class='Disk' OR clay_class='Memory' OR clay_class='Networking, Machine Access' OR clay_class='Shared Storage',1,0)) AS probs, STR_TO_DATE(CONCAT(YEARWEEK(prob_start_date),' Monday'),'%X%V %W') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," AND end_time>=(SELECT MIN(dispatch_time) FROM ",systems[iter],") AND start_time<=(SELECT MAX(dispatch_time) FROM ",systems[iter],") GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'),'%X%V %W');",sep="") } else { failureQuery<-paste("SELECT DISTINCT(STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'),'%X%V %W')) AS date, if(tbl.probs is NULL,0,tbl.probs) FROM ",systems[iter]," LEFT JOIN (SELECT SUM(if(hw_desc!='',1,0)) AS probs, STR_TO_DATE(CONCAT(YEARWEEK(prob_start_date),' Monday'),'%X%V %W') as date FROM failure_data WHERE system=",systemNum[iter],failureDateClamp," AND end_time>=(SELECT MIN(dispatch_time) FROM ",systems[iter],") AND start_time<=(SELECT MAX(dispatch_time) FROM ",systems[iter],") GROUP BY date) as tbl ON tbl.date=STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(dispatch_time)),' Monday'),'%X%V %W');",sep="") } } print(paste("Querying for system",systems[iter])) print(paste("Usage Query:",usageQuery,sep="")) res<- dbSendQuery(con, usageQuery) dat<- fetch(res,n=-1) userTime<-cbind(as.Date(dat[,1]),dat[,2]) print(paste("Usage AVG Query:",usageAVGQuery,sep="")) res<- dbSendQuery(con, usageAVGQuery) userAVGs<- fetch(res,n=-1) print(paste("Failure Query:",failureQuery,sep="")) res<- dbSendQuery(con, failureQuery) dat<- fetch(res,n=-1) failures<-cbind(as.Date(dat[,1]),dat[,2]) #Scale Failures To Have a Range Of 0-1 failures[,2]<-failures[,2]/range(failures[,2][!is.na(failures[,2])])[2] IQR_stats<-boxplot(split(userTime[,2],userTime[,1]),plot=FALSE) userStatTimes<-rbind(IQR_stats$names,IQR_stats$stats) png(paste("/export/MACS370_project/Image/SysVUserTime/user_time_box",systems[iter],"by",QUERY_DATE,".png",sep=""),height=1000,width=1000) if(BOXPLOTS==TRUE && PLOTTING==TRUE) { par(bg="cornsilk",new=T) print("Boxplot...") boxplot(split(userTime[,2],as.Date(dates(userTime[,1]))),style="tukey",main=paste("Plot of userTime as a percentage of totalTime\nSystem",systemNum[iter],sep=""),xlim=as.Date(dates(range(userTime[,1]))),ylim=c(0,1),lwd=.5,plot=TRUE) points(failures[,2],type="p",col=4,cex=10,pch=4,ylim=c(0,1)) dev.off() par(oldpar) # No Boxplots } else if (PLOTTING==TRUE) { par(bg="cornsilk",new=T) print("Plotting...") plot(as.Date(dates(failures[,1])),failures[,2],main=paste("Plot of userTime as a percentage of totalTime\nSystem",systemNum[iter],sep=""),xlim=as.Date(dates(range(userTime[,1]))),ylim=c(0,1),lwd=.5,type="p",col=4,cex=3,pch=4) points(failures,col=4,cex=3,pch=4,ylim=c(0,1)) print("Getting IQR...") lines(userStatTimes[1,],userStatTimes[2,],xlim=as.Date(dates(range(userTime[,1]))),lwd=1) lines(userStatTimes[1,],userStatTimes[3,],xlim=as.Date(dates(range(userTime[,1]))),lwd=1) lines(userStatTimes[1,],userStatTimes[4,],xlim=as.Date(dates(range(userTime[,1]))),lwd=1) lines(userStatTimes[1,],userStatTimes[5,],xlim=as.Date(dates(range(userTime[,1]))),lwd=1) lines(userStatTimes[1,],userStatTimes[6,],xlim=as.Date(dates(range(userTime[,1]))),lwd=1) abline(h=mean(as.numeric(userStatTimes[2,])),lwd=1,lty=4) abline(h=mean(as.numeric(userStatTimes[3,])),lwd=1,lty=4) abline(h=mean(as.numeric(userStatTimes[4,])),lwd=1,lty=4) abline(h=mean(as.numeric(userStatTimes[5,])),lwd=1,lty=4) abline(h=mean(as.numeric(userStatTimes[6,])),lwd=1,lty=4) dev.off() par(oldpar) } print(paste("----- Correlation by:",QUERY_DATE,"For system",systems[iter],"-----")) png(paste("/export/MACS370_project/Image/SysVUserTime/user_time_diff_",systems[iter],"by",QUERY_DATE,".png",sep=""),height=1000,width=1000) # Small Regression V. Diff(UserTime) cors<-cbind(c(diff(userAVGs[,2]),NA),dat[,2]) cors<-cbind(cors[,1][!is.na(cors[,1])],cors[,2][!is.na(cors[,1])]) cors<-cbind(cors[,1][!is.na(cors[,2])],cors[,2][!is.na(cors[,2])]) colnames(cors)<-c("UserTime AVG Diffs","Failures") print(cor(cors)) print(paste("Num. Obs.:",length(cors[,1]))) # Test to cut out s15 yearly avg diffs. (only one data point) if(dim(cors)[1]>2) { # From the R Graph Gallery: # http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=137 panel.cor <- function(x, y, digits=2, prefix="", cex.cor) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") if(missing(cex.cor)) cex <- 0.8/strwidth(txt) test <- cor.test(x,y) # borrowed from printCoefmat Signif <- symnum(test$p.value, corr = FALSE, na = FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c("***", "**", "*", ".", " ")) text(0.5, 0.5, txt, cex = cex * r) text(.8, .8, Signif, cex=cex, col=2) } pairs(cors, lower.panel=panel.smooth, upper.panel=panel.cor,main=paste("System",systems[iter],"by",QUERY_DATE)) dev.off() png(paste("/export/MACS370_project/Image/SysVUserTime/user_time_",systems[iter],"by",QUERY_DATE,".png",sep=""),height=1000,width=1000) # Big Correlation V. UserTime, NumCPU, Job Len. cors<-cbind(userAVGs[,2],userAVGs[,3],userAVGs[,4],dat[,2]) cors<-cbind(cors[,1][!is.na(cors[,1])],cors[,2][!is.na(cors[,1])],cors[,3][!is.na(cors[,1])],cors[,4][!is.na(cors[,1])]) cors<-cbind(cors[,1][!is.na(cors[,4])],cors[,2][!is.na(cors[,4])],cors[,3][!is.na(cors[,4])],cors[,4][!is.na(cors[,4])]) colnames(cors)<-c("UserTime AVGs","Num CPU AVGs","Job Len. AVGs","Failures") print(cor(cors)) print(paste("Num. Obs.:",length(cors[,1]))) # From the R Graph Gallery: # http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=137 panel.cor <- function(x, y, digits=2, prefix="", cex.cor) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") if(missing(cex.cor)) cex <- 0.8/strwidth(txt) test <- cor.test(x,y) # borrowed from printCoefmat Signif <- symnum(test$p.value, corr = FALSE, na = FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c("***", "**", "*", ".", " ")) text(0.5, 0.5, txt, cex = cex * r) text(.8, .8, Signif, cex=cex, col=2) } pairs(cors, lower.panel=panel.smooth, upper.panel=panel.cor,main=paste("System",systems[iter],"by",QUERY_DATE)) } dev.off() if(ACF_PLOT==TRUE) { print("ACF plots") x11() cors<-cbind(userAVGs[,3],dat[,2]) cors<-cbind(cors[,1][!is.na(cors[,1])],cors[,2][!is.na(cors[,1])]) cors<-cbind(cors[,1][!is.na(cors[,2])],cors[,2][!is.na(cors[,2])]) colnames(cors)<-c("UserTime AVG","Failures") acf(cors,main=paste("ACF for system",systemNum[iter]),ci.type="ma",ci=.05) dev.copy(png,file=(paste("/export/MACS370_project/Image/SysVUserTime/ACF_",systems[iter],".png"))) dev.off() } g <- lm(cors[,2] ~ cors[,1]) plot(g$fit,g$res,xlab="Fitted",ylab="Residuals") abline(h=0) plot(g$fit,abs(g$res),xlab="Fitted",ylab="|Residuals|") summary(lm(abs(g$res)~g$fit)) } if(OUTPUT_TEXT!=TRUE) { sink() } } dbDisconnect(con) ------------------------- end script