码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • bihash总结


    官方https://s3-docs.fd.io/vpp/22.10/developer/corearchitecture/bihash.html

    原理分析https://blog.csdn.net/jqh9804/article/details/55100994?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2-55100994-blog-109624119.pc_relevant_multi_platform_whitelistv3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2-55100994-blog-109624119.pc_relevant_multi_platform_whitelistv3&utm_relevant_index=4

    Vpp uses bounded-index extensible hashing to solve a variety of exact-match (key, value) lookup problems. Benefits of the current implementation:

    • Very high record count scaling, tested to 100,000,000 records.

    • Lookup performance degrades gracefully as the number of records increases

    • No reader locking required

    • Template implementation, it’s easy to support arbitrary (key,value) types

    以上介绍了bihash的优点

    Initializing a bihash table

    Call the init function as shown. As a rough guide, pick a number of buckets which is approximately number_of_expected_records/BIHASH_KVP_PER_PAGE from the relevant template instance header-file. See previous discussion.

    The amount of memory selected should easily contain all of the records, with a generous allowance for hash collisions. Bihash memory is allocated separately from the main heap, and won’t cost anything except kernel PTE’s until touched, so it’s OK to be reasonably generous.

    For example:

    my_main_t *mm = &my_main;
    clib_bihash_8_8_t *h;
    
    h = &mm->hash_table;
    
    clib_bihash_init_8_8 (h, "test", (u32) number_of_buckets,
                           (uword) memory_size);
    

    bihash初始化时需要传入buckets大小和memory_size

    buckets最优值:你预期存储的记录数除以BIHASH_KVP_PER_PAGE ,BIHASH_KVP_PER_PAGE 是bihash中一个page存储记录的个数,默认是4.假如存储50万记录

    500000/4=125000

    memory_size:最好就是能存储50万记录,存储解决hash冲突的数据结构,存储buckets,意思是给充足点。bihash  一个记录大小 kv 包含key值和value值。

  • 相关阅读:
    C++ 中的 typeid 运算符和示例
    K8S最常用的命令
    Python实现多子图绘制系统
    Webpack性能优化 SplitChunksPlugin的使用详解
    代码随想录算法训练营第三天| LeetCode ● 203.移除链表元素 ● 707.设计链表 ● 206.反转链表
    【MySQL】索引
    电脑怎么截图,4种简单常用的截图方法
    阿里云Redis
    SpringBoot 整合 MongoDB 实战解说
    白酒:茅台镇白酒的文化内涵与传承意义
  • 原文地址:https://blog.csdn.net/shaoyunzhe/article/details/126123607
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号