~ntietz/isabella-db

a0772d99c1aa076d434a67a14890d1a3fe74442d — Nicole Tietz-Sokolskaya 1 year, 3 months ago c12bccb
Switch from messagepack to bincode crate for faster load/save.

It now takes ~30 seconds to save and ~50 seocnds to load. I think this can be faster
with a custom binary protocol, but I think this is also quite adequate for now.
3 files changed, 15 insertions(+), 6 deletions(-)

M Cargo.lock
M isabella/Cargo.toml
M isabella/src/bin/idb.rs
M Cargo.lock => Cargo.lock +10 -0
@@ 26,6 26,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"

[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
 "serde",
]

[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 108,6 117,7 @@ dependencies = [
name = "isabella-db"
version = "0.1.0"
dependencies = [
 "bincode",
 "clap",
 "pgn",
 "rmp-serde",

M isabella/Cargo.toml => isabella/Cargo.toml +1 -0
@@ 13,6 13,7 @@ pgn = { path = "../pgn" }
smartstring = "1.0.1"

rmp-serde = "1.1.1"
bincode = "1.3.3"

serde = { workspace = true }
shakmaty = { workspace = true }

M isabella/src/bin/idb.rs => isabella/src/bin/idb.rs +4 -6
@@ 4,7 4,6 @@ use std::io::{BufReader, BufWriter};
use clap::{Parser, Subcommand};
use isabella_db::db::GameDB;
use pgn::load::PgnFile;
use serde::Serialize;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::EnvFilter;



@@ 52,16 51,15 @@ fn main() {
                .create(true)
                .open(outfilename)
                .expect("should open file to write");
            let mut writer = BufWriter::new(outfile);
            let mut serializer = rmp_serde::Serializer::new(&mut writer);
            let writer = BufWriter::new(outfile);

            db.serialize(&mut serializer).expect("should serialize");
            bincode::serialize_into(writer, &db).expect("serializing should work");
        }
        Commands::Load => {
            let file: File = File::open(args.filename).expect("should open the file");
            let mut reader = BufReader::new(file);
            let reader = BufReader::new(file);

            let db: GameDB = rmp_serde::from_read(&mut reader).expect("should read teh file back");
            let db: GameDB = bincode::deserialize_from(reader).expect("deserializing should work");
            println!("loaded {} games", db.len());
        }
    };