pijul nest
guest [sign in]

More docs, example, and fixing the free page diagnostic function for mutable transactions

[?]
Feb 21, 2021, 11:16 PM
5LSYTRQ6IOVUW26VJW5SWGFEIB7T2N4PVEB6VMNMR5ZHQ75MFOQAC

Dependencies

  • [2] FZBLNBGN Diagnostic tools (add_refs, check_free) + cleanup
  • [3] 6DCQHIFP Minor changes after benchmarking
  • [4] PXF3R6SV Improving test coverage for btree::cursor
  • [5] G4JEQLLX Debugging synchronisation
  • [6] OFINGD26 implementing prev() on cursors (+ some cleanup)
  • [7] YWFYZNLZ Cleanup + inter-process concurrency
  • [8] 6UVFCERM Formatting, debugging, etc.
  • [9] OTWDDJE7 Trait/type cleanup
  • [10] E4MD6T3L Proofreading and commenting of this crate (massive bug fixes included)
  • [11] OHUZ73MK Versions
  • [12] AFKBHYVE Comparing the two implementations of leaves (sized/unsized). Sized are faster for writes, slower for reads.
  • [13] AOX2XQIS Actually, with the correct functions, Unsized pages are always slower than Sized pages (especially for writing)
  • [14] T7QB6QEP Adding debug.rs
  • [15] OP6SVMOD Resetting history
  • [*] UAQX27N4 Tests
  • [*] W2MIZD5B Single file databases + CRC for the root pages (checking the other pages makes everything very slow)

Change contents

  • replacement in sanakirja/src/tests.rs at line 481
    [3.11860][3.116:143]()
    let n = 10_000_000u64;
    [3.11860]
    [3.11974]
    let n = 1_000u64;
  • edit in sanakirja/src/tests.rs at line 504
    [3.2624]
    [2.1098]
    add_free_refs_mut(&mut txn, &mut refs).unwrap();
  • replacement in sanakirja/src/tests.rs at line 510
    [3.413][3.12602:12694](),[3.12602][3.12602:12694]()
    let mut db = create_db_::<MutTxn<&Env, ()>, u64, u64, UP<u64, u64>>(&mut txn).unwrap();
    [3.413]
    [3.12694]
    let env = Env::new_anon(409_600_000, 1).unwrap();
    let mut txn = Env::mut_txn_begin(&env).unwrap();
    let mut db2 = create_db_::<MutTxn<&Env, ()>, u64, u64, UP<u64, u64>>(&mut txn).unwrap();
  • edit in sanakirja/src/tests.rs at line 514
    [3.12738]
    [3.12762]
    let n = 1_000u64;
  • replacement in sanakirja/src/tests.rs at line 516
    [3.12782][3.442:489](),[3.489][3.2434:2492]()
    debug!("=================== {:?}", i);
    assert!(put(&mut txn, &mut db, &i, &i).unwrap());
    [3.12782]
    [3.12831]
    assert!(put(&mut txn, &mut db2, &i, &i).unwrap());
  • replacement in sanakirja/src/tests.rs at line 521
    [3.604][3.604:651](),[3.651][3.2856:2899]()
    debug!("=================== {:?}", i);
    get(&txn, &db, &i, None).unwrap();
    [3.604]
    [3.701]
    get(&txn, &db2, &i, None).unwrap();
  • replacement in sanakirja/src/tests.rs at line 524
    [3.760][3.2733:3005]()
    println!("unsized length = {:?}", (txn.length >> 12) - len);
    add_refs(&txn, &db, &mut refs).unwrap();
    for (p, r) in refs.iter() {
    if *r >= 2 {
    error!("{:?} referenced twice", p);
    err += 1
    }
    }
    assert_eq!(err, 0);
    [3.760]
    [2.1136]
    refs.clear();
    add_refs(&txn, &db2, &mut refs).unwrap();
    add_free_refs_mut(&mut txn, &mut refs).unwrap();
  • edit in sanakirja/src/lib.rs at line 13
    [18.2979]
    [3.3592]
    //!
    //! Here's an example of how to use it (starting with 64 pages, 2
    //! versions, see below for details about what that means). The file
    //! grows automatically, as needed.
    //!
    //! ```
    //! use sanakirja::*;
    //! let dir = tempfile::tempdir().unwrap();
    //! let path = dir.path().join("db");
    //! let env = Env::new(&path, 1 << 20, 2).unwrap();
    //! let mut txn = Env::mut_txn_begin(&env).unwrap();
    //! let mut db = btree::create_db::<_, u64, u64>(&mut txn).unwrap();
    //! for i in 0..100_000u64 {
    //! btree::put(&mut txn, &mut db, &i, &(i*i)).unwrap();
    //! }
    //! let root_db = 0;
    //! txn.set_root(root_db, db.db);
    //! txn.commit().unwrap();
    //! let txn = Env::txn_begin(&env).unwrap();
    //! let db: btree::Db<u64, u64> = txn.root_db(root_db).unwrap();
    //! assert_eq!(btree::get(&txn, &db, &50_000, None).unwrap(), Some((&50_000, &(50_000 * 50_000))));
    //! for entry in btree::iter(&txn, &db, None).unwrap() {
    //! let (k, v) = entry.unwrap();
    //! assert_eq!(*k * *k, *v)
    //! }
    //! ```
  • replacement in sanakirja/src/environment/muttxn.rs at line 30
    [3.15982][3.27437:27473](),[3.7288][3.27437:27473](),[3.1320][3.27437:27473]()
    rc: Option<btree::Db<u64, ()>>,
    [3.7288]
    [3.7289]
    pub(crate) rc: Option<btree::Db<u64, ()>>,
  • edit in sanakirja/src/debug.rs at line 158
    [2.3071]
    [2.3071]
    } else if txn.free_owned_pages.iter().any(|x| *x == page) {
    continue;
    } else if txn.free_pages.iter().any(|x| *x == page) {
    continue;
  • replacement in sanakirja/src/debug.rs at line 260
    [2.6299][2.6299:6901]()
    let env = txn.env.borrow();
    unsafe {
    let p = &*(env.mmaps.lock()[0].ptr.add(txn.root * PAGE_SIZE)
    as *const crate::environment::GlobalHeader);
    if p.free_db != 0 {
    debug!("add_free_refs: free = 0x{:x}", p.free_db);
    let free_db: Db<u64, ()> = btree::Db::from_page(p.free_db);
    add_refs(txn, &free_db, pages)?;
    }
    if p.rc_db != 0 {
    debug!("add_free_refs: rc = 0x{:x}", p.rc_db);
    let rc_db: Db<u64, ()> = btree::Db::from_page(p.rc_db);
    add_refs(txn, &rc_db, pages)?;
    }
    };
    [2.6299]
    [2.6901]
    if txn.free != 0 {
    debug!("add_free_refs: free = 0x{:x}", txn.free);
    let free_db: Db<u64, ()> = btree::Db::from_page(txn.free);
    add_refs(txn, &free_db, pages)?;
    }
    if let Some(ref rc) = txn.rc {
    debug!("add_free_refs: rc = 0x{:x}", rc.db);
    add_refs(txn, &rc, pages)?;
    }
  • replacement in sanakirja/Cargo.toml at line 3
    [3.108441][3.0:18]()
    version = "1.0.0"
    [3.108441]
    [3.108459]
    version = "1.0.1"