
内存
文章平均质量分 50
自驱
ALOHA HEJA HE
展开
-
【golang map】 深入了解map内部存储协议
/ 我们这样做了,键可能会返回 0 或 2 次)。// 语义上,我们永远不会在它们的桶中移动键(如果。// 如果超过 8 个键散列到一个桶,我们链上。// 放入一个桶数组。// 当哈希表增长时,我们分配一个新数组。// 按遍历顺序返回键(桶#,然后溢出。// 8 个键/元素对。// 用于选择一个桶。// 链序,然后是桶索引)。// 每个散列的高位位以区分条目。// 从旧桶数组复制到新桶数组。// 旧表,如果桶必须检查新表。// 映射迭代器遍历桶数组和。// 增长表,迭代器继续迭代。// 在单个存储桶中。..原创 2022-08-09 21:21:55 · 385 阅读 · 0 评论 -
【kitex】字节开源项目 Kitex 认识「字节缓冲」ByteBuffer
1 项目地址https://github.com/cloudwego/kitex remote/bytebuf.go2 使用示例import ( "fmt" "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/kitex/pkg/protocol/bthrift" "github.com/cloudwego/kitex/pkg/remote")func main() {...原创 2022-01-29 18:14:17 · 663 阅读 · 0 评论 -
【redis】3.0 lpush rpush 源码详解
1 命令表{"rpush",rpushCommand,-3,"wm",0,NULL,1,1,1,0,0}, {"lpush",lpushCommand,-3,"wm",0,NULL,1,1,1,0,0},2 放在前面ZIPLIST and LINKEDLIST/* 空白 ziplist 示例图area |<---- ziplist header ---->|<-- end -->|size 4 bytes 4 bytes原创 2022-01-29 17:29:23 · 1356 阅读 · 0 评论 -
【golang】Mutex 源码浅读
1 Mutex 如果说对于临界资源的操作耗时很长(特别是单个操作就大于 1ms)的话,实际上性能上会有一定的问题,区区200行,所谓大道至简、少即是多。2 内部实现32bit 表示【31-3 等待lock goroutines 数量 】【mutexStarving】【mutexWoken】【mutexLocked】https://www.purewhite.io/2019/03/28/golang-mutex-source/x competes with y over the...原创 2021-12-25 17:28:31 · 439 阅读 · 0 评论 -
【golang】golang 团队对于并发读写数据的建议:并发读写string也不是安全的
IntroductionThe Go memory model specifies the conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine.AdvicePrograms that modify data being simul原创 2021-12-22 22:10:24 · 2758 阅读 · 0 评论 -
【golang】内存逃逸分析
// 分析逃逸,就能进一步优化堆上内存数量,减轻 GC 压力了// golang 逃逸分析最基本的原则是:如果一个函数返回的是一个(局部)变量的地址,那么这个变量就发生逃逸。package mainimport "fmt"func main() { a := 1 other2(&a) a++ fmt.Println(a) // 这里会逃逸}func other() *int { // 这里会逃逸 i := 100 re..原创 2021-12-16 19:27:36 · 308 阅读 · 0 评论 -
【算法】LRU 力扣题目
1 要求O(1)时间复杂度实现 put get LRU 存储实现思路:fast lookups --->hashtable hash表 fast removals --->DoublyLinkedList双向链表2 头插 实现最近访问,length 尾部移除超容元素原创 2021-12-07 10:12:45 · 4062 阅读 · 0 评论 -
【redis】 redis 6.0 驱逐key Pool计算方式 如何完成采样? 阅读源码 evictionPoolPopulate(i, dict, db->dict, p
1.evictionPoolPopulate 算法 // src/evict.c 从左到右 idl time 递增/* This is an helper function for freeMemoryIfNeeded(), it is used in order * to populate the evictionPool with a few entries every time we want to * expire a key. Keys with idle time smaller...原创 2021-12-03 23:45:00 · 630 阅读 · 0 评论 -
【算法】ARC,LRU,LFU思想
1 ARC(Adaptive Replacement Cache): 自适应缓存替换算法,它结合了LRU与LFU,来获得可用缓存的最佳使用。核心思想是:当时访问的数据趋向于访问最近的内容,会更多地命中LRU list,这样会增大LRU的空间; 当系统趋向于访问最频繁的内容,会更多地命中LFU list,这样会增加LFU的空间.整个Cache分成两部分,起始LRU和LFU各占一半,后续会动态适应调整partion的位置(记为p) 除此,LRU和LFU各自有一个ghost list(因此,一共4个li原创 2021-12-01 23:45:00 · 1590 阅读 · 0 评论 -
【golang】GCache Supports expirable LFU, LRU and ARC
1 特性 Supports expirable Cache, LFU, LRU and ARC. Goroutine safe. Supports event handlers which evict, purge, and add entry. (Optional) Automatically load cache if it doesn't exists. (Optional) 2 使用Loading CacheIf specified LoaderFu原创 2021-11-30 21:55:54 · 248 阅读 · 0 评论 -
【redis】从GET命令,深入redis 6.0 渐进式扩容
【redis】从GET命令,深入redis渐进式扩容// Get 命令定义struct redisCommand redisCommandTable[] = { {"module",moduleCommand,-2, "admin no-script", 0,NULL,0,0,0,0,0,0}, {"get",getCommand,2, "read-only fast @string", 0,NULL,1,1,1,0,0,0}, ...原创 2021-11-19 12:10:42 · 510 阅读 · 0 评论 -
【mysql】慢查询,大数据量查询优化case U CAN LEARN
1 背景如果mysql扫描数据行数W级别(比如2W)但是每行数据都有一个大json平均几十K比如(20K),此时需要qos如果等于2,多少数据会进入内存呢?估算:20,000 * 2 * 20,000 = 800,000,000 byte 即 大约 800M的数据会进去server内存空间; 呕吼,要报警了!!2 问题根据常识线上业务需要的数据量肯定没有这么多,大约10M到80M就已经很多了,所以如何优化呢?3 解决方案步骤:扫描数据过多,大部分数据是无效的,所以 red.原创 2021-11-18 15:33:03 · 1169 阅读 · 0 评论 -
【斯坦福大学】图形实验室 二进制文章集合
内容直达:thttp://graphics.stanford.edu/~seander/bithacks.html【斯坦福大学】官网https://www.stanford.edu/原创 2021-11-18 23:00:00 · 350 阅读 · 0 评论 -
【golang】pprofile 内存 CPU 分析(火焰图)
1 测试源码package mainimport ( "flag" "fmt" "log" "net/http" _ "net/http/pprof" "os" "runtime" "runtime/pprof" "time")var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")var memprofile = flag.S原创 2021-11-17 19:31:51 · 2124 阅读 · 0 评论 -
【redis】redis 6.0 scanGenericCommand之SCAN 源码解读
1 算法介绍Pieter Noordhuis/* This command implements SCAN, HSCAN and SSCAN commands. * If object 'o' is passed, then it must be a Hash, Set or Zset object, otherwise * if 'o' is NULL the command will operate on the dictionary associated with * ..原创 2021-11-16 23:46:01 · 576 阅读 · 1 评论 -
TCMalloc : Thread-Caching Malloc
Sanjay Ghemawat, Paul Menage <opensource@google.com>MotivationTCMalloc is faster than the glibc 2.3 malloc (available as a separate library called ptmalloc2) and other mallocs that I have tested. ptmalloc2 takes approximately 300 nanoseconds to..原创 2021-11-15 19:55:52 · 356 阅读 · 0 评论 -
golang--TCmalloc 内存管理--原始文章
TCMalloc : Thread-Caching Malloc原创 2021-11-12 16:32:15 · 408 阅读 · 0 评论 -
【集合】java 集合 quick review all-in-one
3.1. 接口继承关系和实现1. Collection:Collection 是集合 List、Set、Queue 的最基本的接口。 2. Iterator:迭代器,可以通过迭代器遍历集合中的数据 3. Map:是映射表的基础接口Java 的 List 是非常常用的数据类型。List 是有序的 Collection。Java List 一共三个实现类:3.2. List分别是 ArrayList、Vector 和 LinkedList。3.2.1. ArrayList(数组原创 2021-02-18 19:52:55 · 179 阅读 · 0 评论