Try configuring approximately nbuckets = (nitems / BIHASH_KVP_PER_PAGE). Make sure that the hash function performs reasonably well on the particular keys involved.
The scheme tolerates a mis-sized bucket array - lookup performance won't change, to a first approximation - but space utilization becomes an issue as you discovered. In the case at hand: try 64k buckets instead of 1k buckets... HTH... Dave -----Original Message----- From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Andreas Schultz Sent: Wednesday, July 17, 2019 11:58 AM To: vpp-dev@lists.fd.io Subject: [vpp-dev] bihash memory fragmentation Hi, I've run into bihash crashing VPP with an out-of-memory error. After investigation I found that the bihash has reached its configured memory limit with far less entries that I would have expected. Some numbers: Type: bihash_8_8 bihash max. memory: 64MB Buckets: 1024 Entries 200k With that number it turns out that almost all buckets have 2^9 pages (512 pages). On average 200 entries per bucket are actually used. The total memory consumption from the buckets and pages should be 1024 * sizeof(bucket) + 1024 * 2^9 * sizeof(page) = 33 MB Yet the bihash has consumed all 64MB (alloc_arena_next > memory_size). It turned out that the missing memory was in the freelists for smaller page sizes. I have resized the bihash to have more buckets to avoid the large pages. Is there anything else I can do? I was thinking about enhancing bihash to specify a initial page size. This would waste some memory while the hash is growing, but would later avoid the fragmentation. Does that make sense? Regards Andreas -- Andreas Schultz -- Principal Engineer t: +49 391 819099-224 ------------------------------- enabling your networks ----------------------------- Travelping GmbH Roentgenstraße 13 39108 Magdeburg Germany t: +49 391 819099-0 f: +49 391 819099-299 e: i...@travelping.com w: https://www.travelping.com/ Company registration: Amtsgericht Stendal Reg. No.: HRB 10578 Geschaeftsfuehrer: Holger Winkelmann VAT ID: DE236673780
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#13519): https://lists.fd.io/g/vpp-dev/message/13519 Mute This Topic: https://lists.fd.io/mt/32504802/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-