From 2edb2453d094c59771d5dd788db75faa0e18410f Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 28 Mar 2019 22:45:25 -0400 Subject: [PATCH] update README --- README.md | 23 +++++++++++++++++++++-- html/img/flat_mem_usage.gif | Bin 0 -> 1755 bytes html/img/node_mem_usage.gif | Bin 0 -> 2008 bytes parallel_hashmap/phmap_fwd_decl.h | 4 ++-- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 html/img/flat_mem_usage.gif create mode 100644 html/img/node_mem_usage.gif diff --git a/README.md b/README.md index 92325d2..2ba3aa2 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,19 @@ int main() ## Various hash maps and their pros and cons -Key points: +The header `parallel_hashmap/phmap.h` provides the implementation for the following eight hash tables: +- phmap::flat_hash_set +- phmap::flat_hash_map +- phmap::node_hash_set +- phmap::node_hash_map +- phmap::parallel_flat_hash_set +- phmap::parallel_flat_hash_map +- phmap::parallel_node_hash_set +- phmap::parallel_node_hash_map + +The full types with template parameters can be found in the [parallel_hashmap/phmap_fwd_decl.h](https://raw.githubusercontent.com/greg7mdp/parallel-hashmap/master/parallel_hashmap/phmap_fwd_decl.h) header, which is useful for forward declaring the Parallel Hashmaps when necessaary. + +**Key points:** - The `flat` hash maps may move the keys and values in memory. So if you keep a pointer to something inside a `flat` hash map, this pointer may become invalid when the map is mutated. The `node` hash maps don't, and should be used instead if this is a problem. @@ -83,6 +95,13 @@ Key points: ## Memory usage - +| type | memory usage | +|--------|-------------------| +| flat tables | ![flat_mem_usage](https://github.com/greg7mdp/parallel-hashmap/blob/master/html/img/flat_mem_usage.gif?raw=true) | +| node tables | !node_mem_usage](https://github.com/greg7mdp/parallel-hashmap/blob/master/html/img/node_mem_usage.gif?raw=true) | + +The load factor varies between 0.4375 (just after the resize) and 0.875 (just before the resize). + +In addition, when the table resizes, the peak memory usage is an additional 50% of the new size for the *non-parallel* hashmaps, and an additional 3% of the new size for the *parallel* hashmaps (single threaded usage). diff --git a/html/img/flat_mem_usage.gif b/html/img/flat_mem_usage.gif new file mode 100644 index 0000000000000000000000000000000000000000..f14b0986a196e3310093bfc1dff2f057da8e8232 GIT binary patch literal 1755 zcmV<11|<1MNk%w1VPpX-0J8u9|Ns90007+F+=z&Xc6N4{n3!f}X729p5D*Z|%*;eY zL?R+0GBPr{y1J^Ws#H`|A^8LW00000EC2ui0Av9x000F35XecZy*TU5^(j(ubYy9s zXsWJk>%MR-v&MAPbFS}v@BcuV1F;$;D2+jI$!t2G(BMI^Vpy!vtai)odNl=5W#IUl z&*-!|rJz<4kF|VGubUj<0<}@VO&$m!4Q>E=1QSFTiFS;Qj%W>s00aXc00>7R4haJU zVgL$a2@Mj96#g%cs&zBMoy`&Ni^Z;e!)&RiirR)F$&alKo z0k8x(2pm!ZpuvLy4G?BxaIZk7HWuJW`DBKmKpp-ffP_@ROb4Gl&7uJV!E3?0T+$|l zu|OtB$uBp(2w=G81`wYYc6#bl4uFwI2NYZha+Jdm9ybOsYg!@K0|Nt;>|{b9P!0j# zUL+Z);9fnR6I@w4fQbT@M+Cm{3G#Nsl!6W%Fsqw(!8Za6%mP_Z^hKx~d|3$a6hJTl zz6vB!7|<&OM@N2u{+OvnUj@z-6exW&YYAH&A7Th#3ZUMsNM~^rl!$045go8x zT5;TRW1SQH@|=gR{W8vi6Ub6%WsM$V>Zz!vs_Lq&w(9Duu*MoHsm&adOjcB6V?=!s~7pG;q$c-~@`K0yQ9TZE>1f zV8D?_GQa@3Rc3%^rXvIZYKU*)m}U$1*4Is*Zz{_l*0Uc9F3ALE ziIawS82}9zGTOf#a7#hO1H7eU03wvANCzEu@a{jL95(@F`}BA(3Fo+jNIdgQV2_0S z*d|W35-@OVv?EhsfXX)}oPy5zQDMx=N|8d&T@xVPZUdg#fWcu0(1UbjQ3LZ^)o#wb zsmZP-!j@Uf78l&hY?NaVI0-FO&qEOzK%`7Z5GDc8;u*d60%&offdE0mS-1sAe?lCb z?iC{JWjY(`fB>XWgtssLNAMK6bjG;Bz}+Dz zNqL@-xDtWtDY^Y*_F+&u2DvB@fP3GpRzgx3Y^CM{$)1r}PW%wF5CTq?+d z6`~*~dV2waHsFp3u_1ybNDKon*n>d4M*}=$2TVF$b}0!38dWr|y^TU<-u`YOsUIH5Qpm^*t6X?;y^~7cYC*JXrUigpD7-BCY zeM<~S>VS?U#v~*eKoX7H(gd`0nyiV6N|Ip?05M6+GZ>0PcOpdr1_V1^c7S=iBvc6A zq70D*Gio<`BeD!8fpXRInP1>rDSm~WODN6_&Pq}g0hmoqS~FXw$R@CaGp{{u?2OP% zrxSD(FbSceo%u-wJmaW=f*}iH@)Q}RLM5_+K}tx>v7|Z&%7dp-!H7P~PoSE%w7oTL z1JYC|(~cU_&`@p3m0n8d!!Qs~f_l^mkINLakhC}fG!6tMJ?RFTgpOUPw2gxDi&2_6 zQkfudj-&giPJiHucld6SHiO>e9s&!YN-tih+L&M>5j~>9>3rVPLlJ++kw#j8ct%Oz xPPZD2S%TDm4CJaK-it{#m506QcF>0kf= literal 0 HcmV?d00001 diff --git a/html/img/node_mem_usage.gif b/html/img/node_mem_usage.gif new file mode 100644 index 0000000000000000000000000000000000000000..77dec05f96e6dcecde059d0cc29f6ce19a887918 GIT binary patch literal 2008 zcmV;}2PgPPNk%w1VVMCd0J8u9|Ns90007+F+=z&Xc6N4{n3!f}X729p5D*Z|%*;eY zL?R+0GBPr{y1J^Ws#H`|A^8LW00000EC2ui0GR%MR-&opIB$6fDy@BhG{aM*GnR)YkkF(?uS1|@Myty-^G;z6)tSiGx(VzS_7 z&*-#z%^np#m4Rawm`ez{wtmm=`&|lV6bTO+1Q`MW4HE@Ne~*xnk}nQ#1zZgUc@hr@ z9}R+*hZ2q!r56i`ii`o1uCK7M4WmyU00>e51r7-V1aJTfa0!dI7_Al$hlOIOzy<+= zvD4JmXm}DLi-{Kkzyx3i1R?^ds3H~v59*7x}NJqZB;3c1+c*&$`X z61s927TBXOV8J*2zb@lQL)jV>fm4Lc}xCaIXG_g#C zfTtM(SifLWfp`Tx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H6@tXaSAB|V#X*wn7Ilqtr-^t6k`EiqUM>3gUu08#ypgu z;{MpQObzHR1;V63J7EAzNO*z(vIM|9E0URj)GL~I$xI615;5YLvz(lhCI@JFD02n}_j9ADQ(-{MFY9K@_XdP5Ms7@}r^raX8rj@Y7 z%{8@&A##9C2e^b!oU(~Im1yLhw52K<(Nqdoy2K=xS3Q_I^{FJ0Mzjv+tGdDAR~&e! zv^X&^1B{}FTRopu4%9!B0l;U*xPUI9%GPcz>?r(N#J*hU#e|Juak{W;UiT8fP{ef+ zC{@hTlmybY8ulgSBLy&eq6D)cU{PgrB@U|PSja}|6lP;AiTnmIy&d+mInrGs1Od9y z637vzH5RQJu%y(sF16ws7;Hgzv5+7Mw76x;{J6lj>owthpot%FeMv73BsOS<5pK1( zjKDuoh|em$HJ@~IOI?cmkPIx`2swIKsqG#jqh|%%4h6v76&i*MO0fz$6Fb)nFtCc% zjc-LFS+YJBW)_XiiZ&QIMEwSgWgjCCe*62#dAQ91n>?3&#Z^v+mQubDhVWX4U`q<% qGQt>ct2TH!1a3kn!yx|bJ@ZL~dWQJKY_%wbyjWNiyZ8kW0028H`Aw?; literal 0 HcmV?d00001 diff --git a/parallel_hashmap/phmap_fwd_decl.h b/parallel_hashmap/phmap_fwd_decl.h index d6b861d..a0e2e40 100644 --- a/parallel_hashmap/phmap_fwd_decl.h +++ b/parallel_hashmap/phmap_fwd_decl.h @@ -35,10 +35,10 @@ namespace phmap { template using hash_default_eq = typename container_internal::HashEq::Eq; - // alias for std::allocator so we can forward declare without including other headers + // type alias for std::allocator so we can forward declare without including other headers template using Allocator = typename phmap::Allocator; - // alias for std::pair so we can forward declare without including other headers + // type alias for std::pair so we can forward declare without including other headers template using Pair = typename phmap::Pair; } // namespace container_internal