options(width = 80) library(data.table) library(ggplot2) dt <- data.table(read.table("webcachesim.log")) setnames(dt,colnames(dt),c("t","type","size","param","h","r","b")) dt <- dt[,list(h=max(h)),by=list(type,size,param,r)] # dt[,list(h1=max(h),h2=min(h)),by=list(type,size,param,r)][h1!=h2] setkey(dt,type,size,param) dt[,ohr:=h/r] # opt param dt2 <- dt[type=="ExpLRU"] dt3 <- dt2[,list(param,ohr,mohr=max(ohr)),by=size] dt4 <- dt3[ohr==mohr] pl <- ggplot(dt4,aes(size,param))+ geom_line()+ scale_x_continuous("Cache size",breaks=c(30+log2(50),30+log2(100),30+log2(200),30+log2(400)),labels=c("50GB","100GB","200GB","400GB"))+ scale_y_continuous("Optimal c param",breaks=(13:22),labels=paste(2^((13:22)-10),"KB"))+ theme_grey(base_size = 22) png(paste("/tmp/explru-param.png",sep=""),500,300) print(pl) dev.off() # (log-log) linear fit fit <- lm(param ~ size, data = dt4) bbase <- fit$coefficients[1]*-1 rrate <- fit$coefficients[2] dt4 linfn <- function(s) s^rrate/2^bbase log2(linfn(2^(dt4$size))) # filter param scaling dt2 <- dt[type=="Filter"] dt3 <- dt2[,list(param,ohr,mohr=max(ohr)),by=size] pl <- ggplot(dt3[ohr==mohr],aes(size,param))+ geom_line()+ scale_x_continuous("Cache size",breaks=c(30+log2(50),30+log2(100),30+log2(200),30+log2(400)),labels=c("50GB","100GB","200GB","400GB"))+ scale_y_continuous("Optimal N param",breaks=(seq(4,50,by=4)),labels=seq(4,50,by=4))+ theme_grey(base_size = 22) png(paste("/tmp/filter-param.png",sep=""),500,300) print(pl) dev.off() # hit ratio graphs dt5 <- dt[,list(ohr=max(ohr)),by=list(size,type)] lbreaks=c("ExpLRU","Filter","LRU") llabels=c("Exp-size","Filter","LRU") dt6 <- dt5[type %in% lbreaks] dt6[,ttype:=factor(type,levels=lbreaks,labels=llabels,ordered=TRUE)] dt6[,type2:=factor(type,levels=lbreaks,ordered=TRUE)] pl <- ggplot(dt6,aes(size,ohr,color=ttype))+ geom_line(size=1.5)+ scale_x_continuous("Cache size",breaks=c(30+log2(50),30+log2(100),30+log2(200),30+log2(400)),labels=c("50GB","100GB","200GB","400GB"))+ scale_y_continuous("Hit ratio")+ scale_colour_brewer("",palette="Set1")+ theme_grey(base_size = 22) png(paste("/tmp/hitratio-cap.png",sep=""),500,300) print(pl) dev.off() # sensititivy graphs dt2 <- dt[type=="Filter"] setkey(dt2,ohr) setkey(dt2,param) pl <- ggplot(dt2,aes(param,ohr,color=factor(size)))+ geom_line(size=1.5)+ scale_x_continuous("Admit after N requests",breaks=(1:10)*10)+ scale_y_continuous("Hit Ratio",breaks=c(0.75,0.8,0.85,.9,.95))+ scale_colour_brewer("",palette="Set1",breaks=rev(dt2[size!=38.325,unique(size)]), labels=rev(paste( dt2[size!=38.325,round(2^(unique(size)-30))], "GB")))+ theme_grey(base_size = 22)+ coord_cartesian(ylim=c(0.75,0.95)) png(paste("/tmp/Filter-sensitivity.png",sep=""),500,400) print(pl) dev.off() dt2 <- dt[type=="ExpLRU"] setkey(dt2,ohr) setkey(dt2,param) pl <- ggplot(dt2,aes(param,ohr,color=factor(size)))+ geom_line(size=1.5)+ scale_x_continuous("Exp param c",breaks=c(10,12,14,16,18,20,22),labels=c("1KB","4KB","16KB","64KB","256KB","1MB","4MB"))+ scale_y_continuous("Hit Ratio",breaks=(1:50)/50)+ scale_colour_brewer("",palette="Set1",breaks=rev(dt2[size!=38.325,unique(size)]), labels=rev(paste( dt2[size!=38.325,round(2^(unique(size)-30))], "GB")))+ theme_grey(base_size = 22) + coord_cartesian(ylim=c(0.85,0.98)) png(paste("/tmp/ExpLRU-sensitivity.png",sep=""),500,400) print(pl) dev.off()