码农知识堂 - 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值。

  • 相关阅读:
    Redis高可用
    面试必备:2019年Java 最常见 100+ 面试题解析
    dflow入门2——Slices
    Java学习笔记5.3.1 Set接口 - HashSet类
    20. 【Linux教程】emacs 编辑器
    SQL基础语句
    (附源码)计算机毕业设计SSM教务管理系统
    Python开发工具
    深度学习入门:针对deep-learning-for-image-process文件的学习
    可扩展性对物联网管理系统有哪些影响?
  • 原文地址: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号