-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
5,349 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
library(ggplot2) | ||
library(ggrepel) | ||
library(patchwork) | ||
library(data.table) | ||
library(dplyr) | ||
library(this.path) | ||
library(stringplus) | ||
set_string_ops("&", "|") | ||
|
||
options(warn=1) | ||
|
||
PLATFORM <- "ubuntu" | ||
DATA_PATH <- "~/datasets/processed" | ||
datasets <- DATA_PATH & "/" & c("1000genomes_noncoding_vcf.csv.gz", "B_cell_petshopmouse3.tsv.gz", | ||
"ip_location_2023.csv.gz", "Netflix_Ratings.csv.gz") | ||
read_dataset <- function(d) { | ||
if(d %like% "json.gz") { | ||
DATA <- RcppSimdJson::fload(d) | ||
} else if(d %like% ".csv.gz") { | ||
DATA <- fread(d, sep = ",", data.table=F) | ||
} else if(d %like% ".tsv.gz") { | ||
DATA <- fread(d, sep = "\t", data.table=F) | ||
} else { | ||
DATA <- readRDS(d) | ||
} | ||
} | ||
|
||
df <- lapply(datasets, function(DATASET) { | ||
obj_size <- read_dataset(DATASET) %>% object.size() %>% as.numeric %>% {. / 1048576} | ||
DATASET_NAME <- basename(DATASET) %>% gsub("\\..+", "", .) | ||
print(DATASET_NAME) | ||
fread("%s/results/%s_serialization_benchmarks_%s.csv" | c(this.dir(), PLATFORM, DATASET_NAME)) %>% | ||
mutate(dataset = DATASET_NAME, obj_size = obj_size) | ||
}) %>% rbindlist | ||
|
||
dfs <- df %>% | ||
group_by(algo, nthreads, compress_level, dataset, obj_size) %>% | ||
summarize(file_size = max(file_size), save_time = median(save_time), read_time = median(read_time)) | ||
|
||
g1 <- ggplot(df %>% filter(algo %like% "^q" | algo == "parquet"), | ||
aes(x = file_size, y = save_time, color = algo, shape = factor(nthreads))) + | ||
geom_point() + | ||
geom_line(data = dfs %>% filter(algo %like% "^q" | algo == "parquet"), | ||
aes(lty = factor(nthreads))) + | ||
scale_x_log10() + | ||
scale_y_log10() + | ||
facet_wrap(~dataset, scales="free") + | ||
scale_color_manual(values = palette.colors(palette = "Okabe-Ito")) + | ||
labs(color = "Format", lty = "Threads", pch = "Threads", | ||
x = "File Size (MB)", y = "Save Time (s)") + | ||
theme_bw(base_size=11) + | ||
guides(color = guide_legend(order = 1), | ||
pch = guide_legend(order = 2), | ||
lty = guide_legend(order = 2)) | ||
|
||
|
||
g2 <- ggplot(df %>% filter(algo %like% "^q" | algo == "parquet"), | ||
aes(x = save_time, y = read_time, color = algo, shape = factor(nthreads))) + | ||
geom_point() + | ||
geom_line(data = dfs %>% filter(algo %like% "^q" | algo == "parquet"), | ||
aes(lty = factor(nthreads))) + | ||
scale_x_log10() + | ||
scale_y_log10() + | ||
facet_wrap(~dataset, scales="free") + | ||
scale_color_manual(values = palette.colors(palette = "Okabe-Ito")) + | ||
labs(color = "Format", lty = "Threads", pch = "Threads", | ||
x = "Save Time (s)", y = "Read Time (s)") + | ||
theme_bw(base_size=11) + | ||
guides(color = guide_legend(order = 1), | ||
pch = guide_legend(order = 2), | ||
lty = guide_legend(order = 2)) | ||
|
||
ggsave(g1, file = "plots/%s_write_benchmarks.png" | PLATFORM, width = 7, height = 5) | ||
ggsave(g2, file = "plots/%s_read_benchmarks.png" | PLATFORM, width = 7, height = 5) | ||
|
||
################################################################################ | ||
# Summary table | ||
|
||
|
||
dfs2 <- dfs %>% | ||
filter( (algo %like% "^q" & compress_level == 3) | | ||
(algo == "rds") | | ||
(algo == "base_serialize") | | ||
(algo == "fst" & compress_level == 50) | | ||
(algo == "parquet" & compress_level == 3)) | ||
|
||
dfs2 %>% | ||
mutate(compression = obj_size / file_size) %>% | ||
group_by(algo, nthreads) %>% | ||
summarize(compression = mean(compression), save_time = sum(save_time), read_time = sum(read_time)) %>% | ||
arrange(algo, nthreads) %>% as.data.frame | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# helper script for copy and reading benchmarks | ||
suppressPackageStartupMessages({ | ||
library(dplyr, quietly=TRUE) | ||
library(stringplus, quietly=TRUE) | ||
}) | ||
|
||
set_string_ops("&", "|") | ||
|
||
args <- commandArgs(trailingOnly = TRUE) | ||
algo <- args[1] | ||
nthreads <- args[2] %>% as.numeric | ||
file_path <- args[3] # must be full path not relative | ||
output_temp_file <- args[4] # write results to here | ||
|
||
now <- function() assign(".time", Sys.time(), envir = globalenv()) | ||
later <- function() { as.numeric(Sys.time() - get(".time", envir = globalenv()), units = "secs") } | ||
|
||
# now() | ||
# x <- file.copy(file_path, copy_path) | ||
# copy_time <- later() | ||
if(algo == "base_serialize") { | ||
now() | ||
con <- file(file_path, "rb") | ||
unserialize(con) | ||
close(con) | ||
read_time <- later() | ||
} else if(algo == "rds") { | ||
now() | ||
x <- readRDS(file = file_path) | ||
read_time <- later() | ||
} else if(algo == "qs-legacy") { | ||
suppressPackageStartupMessages( library(qs, quietly=TRUE) ) | ||
now() | ||
x <- qs::qread(file_path, nthreads = nthreads) | ||
read_time <- later() | ||
} else if(algo == "qs2") { | ||
suppressPackageStartupMessages( library(qs2, quietly=TRUE) ) | ||
now() | ||
x <- qs2::qs_read(file_path, validate_checksum = FALSE, nthreads = nthreads) | ||
read_time <- later() | ||
} else if(algo == "qdata") { | ||
suppressPackageStartupMessages( library(qs2, quietly=TRUE) ) | ||
now() | ||
x <- qs2::qd_read(file_path, validate_checksum = FALSE, nthreads = nthreads) | ||
read_time <- later() | ||
} else if(algo == "fst") { | ||
suppressPackageStartupMessages( library(fst, quietly=TRUE) ) | ||
fst::threads_fst(nr_of_threads = nthreads) | ||
now() | ||
x <- fst::read_fst(path = file_path) | ||
read_time <- later() | ||
} else if(algo == "parquet") { | ||
suppressPackageStartupMessages( library(arrow, quietly=TRUE) ) | ||
options(arrow.use_altrep = FALSE) # don't use ALTREP/mmap for benchmark | ||
arrow::set_cpu_count(num_threads = nthreads) | ||
now() | ||
x <- arrow::read_parquet(file = file_path, mmap = FALSE) | ||
read_time <- later() | ||
} | ||
|
||
writeLines(text = c(read_time) %>% as.character, con = output_temp_file) | ||
|
Oops, something went wrong.