library(tidyverse)
library(ggpmisc)
library(scales)


read_csv("s3billion-dc-gros-32threads-256batchsize-128000batchcount-v0.8-fix-time-30M.csv") %>% mutate(batch_dur_sec = batch_dur_nanoseconds / 1000 / 1000 / 1000) %>% filter(total_objects != 0) -> s

reg <- lm(s$batch_dur_sec~s$total_objects)

f <- y~x

ggplot(s, aes(x=total_objects, y=batch_dur_sec)) +
  geom_point(shape = "bullet", alpha=0.4) +
  geom_smooth(method="lm", formula=f, se = FALSE, color="blue") + 
  scale_x_continuous(expand=c(0,0), breaks = scales::pretty_breaks(n = 10), labels = unit_format(unit = "M", scale = 1e-6)) +
  scale_y_continuous(expand=c(0,0), breaks = scales::pretty_breaks(n = 10)) +
  coord_cartesian(ylim=c(0,3)) +
  labs(
    y="Time (in sec) spent sending a batch (8192 objects)",
    x="Total number of objects stored in the cluster",
    caption="Get the code to reproduce this graph at https://git.deuxfleurs.fr/Deuxfleurs/mknet",
    title="Storing 30M small objects in Garage!",
    subtitle="Daemon: Garage v0.8.0-rc1 (+ #398 pull request) with LMDB as db_engine\nBenchmark: 8192 objects/batch. 32 threads/batch. 256 objects/thread. 16-byte/objects.\nEnvironment: mknet on Grid'5000 (gros) https://www.grid5000.fr/w/Nancy:Hardware#gros (SATA SSD).\nDC topo (3 logical nodes, 1Gb/s, 1ms latency).") +
  theme_classic()
ggsave("./garage-0.8-gros.png", width=200, height=120, units="mm")
#ggsave("./garage-regression.png", width=200, height=120, units="mm")

