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

  • 相关阅读:
    Spring(一)- 初始 + DI+scope
    机器学习One-Hot编码
    Andorid 13 修改默认音量区间、默认音量值
    Python实现KNN(K近邻)分类模型(KNeighborsClassifier算法)并应用网格搜索算法寻找最优参数值以及数据标准化均衡化项目实战
    JVM基本概念、命令、参数、GC日志总结
    若依SpringBoot+Vue分离版打包部署(前端)
    腾讯云TI平台持续升级,TI-ACC训练加速性能较原生框架提升超30%
    SINetv2:Concealed Object Detection——论文简述
    Fiddler抓包工具详解
    cors基础,响应头设置
  • 原文地址:https://blog.csdn.net/shaoyunzhe/article/details/126123607
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号