diff --git a/blockstore_flush.h b/blockstore_flush.h index 294bd0a5..740f3fa8 100644 --- a/blockstore_flush.h +++ b/blockstore_flush.h @@ -46,7 +46,7 @@ class journal_flusher_co std::function simple_callback_r, simple_callback_w; bool skip_copy, has_delete, has_empty; - spp::sparse_hash_map::iterator clean_it; + blockstore_clean_db_t::iterator clean_it; std::vector v; std::vector::iterator it; int copy_count; diff --git a/blockstore_impl.h b/blockstore_impl.h index 874e7e0d..c4c81cb2 100644 --- a/blockstore_impl.h +++ b/blockstore_impl.h @@ -16,7 +16,7 @@ #include #include -#include "sparsepp/sparsepp/spp.h" +#include "cpp-btree/btree_map.h" #include "allocator.h" @@ -164,6 +164,10 @@ struct blockstore_op_private_t int sync_state, prev_sync_count; }; +// https://github.com/algorithm-ninja/cpp-btree +// https://github.com/greg7mdp/sparsepp/ was used previously, but it was TERRIBLY slow after resizing +// with sparsepp, random reads dropped to ~700 iops very fast with just as much as ~32k objects in the DB +typedef btree::btree_map blockstore_clean_db_t; typedef std::map blockstore_dirty_db_t; #include "blockstore_init.h" @@ -198,8 +202,7 @@ class blockstore_impl_t struct ring_consumer_t ring_consumer; - // Another option is https://github.com/algorithm-ninja/cpp-btree - spp::sparse_hash_map clean_db; + blockstore_clean_db_t clean_db; uint8_t *clean_bitmap = NULL; blockstore_dirty_db_t dirty_db; std::list submit_queue; // FIXME: funny thing is that vector is better here diff --git a/osd.h b/osd.h index 7784db9f..97c735f2 100644 --- a/osd.h +++ b/osd.h @@ -19,8 +19,6 @@ #include "osd_ops.h" #include "osd_peering_pg.h" -#include "sparsepp/sparsepp/spp.h" - #define OSD_OP_IN 0 #define OSD_OP_OUT 1 diff --git a/osd_peering_pg.cpp b/osd_peering_pg.cpp index 0db329a2..4babecf0 100644 --- a/osd_peering_pg.cpp +++ b/osd_peering_pg.cpp @@ -93,7 +93,7 @@ void pg_t::remember_object(pg_obj_state_check_t &st, std::vector & } if (state & (OBJ_NEEDS_ROLLBACK | OBJ_NEEDS_STABLE)) { - spp::sparse_hash_map pieces; + std::unordered_map pieces; for (int i = st.obj_start; i < st.obj_end; i++) { auto & pcs = pieces[(obj_piece_id_t){ .oid = all[i].oid, .osd_num = all[i].osd_num }]; diff --git a/osd_peering_pg.h b/osd_peering_pg.h index 62ba3d6b..571d9edc 100644 --- a/osd_peering_pg.h +++ b/osd_peering_pg.h @@ -1,12 +1,13 @@ #include +#include #include #include +#include "cpp-btree/btree_map.h" + #include "object_id.h" #include "osd_ops.h" -#include "sparsepp/sparsepp/spp.h" - // Placement group states // Exactly one of these: #define PG_OFFLINE (1<<0) @@ -64,8 +65,8 @@ struct osd_op_t; struct pg_peering_state_t { // osd_num -> list result - spp::sparse_hash_map list_ops; - spp::sparse_hash_map list_results; + std::unordered_map list_ops; + std::unordered_map list_results; int list_done = 0; }; @@ -122,9 +123,9 @@ struct pg_t // it may consume up to ~ (raw storage / object size) * 24 bytes in the worst case scenario // which is up to ~192 MB per 1 TB in the worst case scenario std::map state_dict; - spp::sparse_hash_map obj_states; + btree::btree_map obj_states; std::map obj_stab_actions; - spp::sparse_hash_map ver_override; + btree::btree_map ver_override; pg_peering_state_t *peering_state = NULL; std::multimap write_queue;