V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Nazz  ›  全部回复第 12 页 / 共 46 页
回复总数  911
1 ... 8  9  10  11  12  13  14  15  16  17 ... 46  
2023-12-11 17:21:00 +08:00
回复了 Nazz 创建的主题 Go 编程语言 用动态数组模拟链表做 GC 优化这个主意怎么样
@flynnlemon bucket 是缓存库的基本存储结构, 源码见 https://github.com/lxzan/memorycache/tree/swiss .
现在的代码里面直接用指针式链表维护 LRU 缓存了, 实测数组链表对于 GC 优化帮助不大. 虽然数据表面都是值类型, 但实际上 string 底层是有指针的, any 可能也会被扫描.
2023-12-11 08:42:48 +08:00
回复了 Nazz 创建的主题 Go 编程语言 用动态数组模拟链表做 GC 优化这个主意怎么样
@flynnlemon 这里只讨论 GC
2023-12-07 18:56:14 +08:00
回复了 steelshadow39 创建的主题 Java 讨论 Java 相比其他编程语言(c++, go, rust 等)的缺点
2023-12-07 17:29:10 +08:00
回复了 steelshadow39 创建的主题 Java 讨论 Java 相比其他编程语言(c++, go, rust 等)的缺点
@zhazi springboot data jdbc 那一段,看了半天都不知道 @Query 怎么用,去 github 看了下别人的 demo 一下就会了
2023-12-07 10:52:56 +08:00
回复了 steelshadow39 创建的主题 Java 讨论 Java 相比其他编程语言(c++, go, rust 等)的缺点
@zhazi 不是公认的烂吗
2023-12-06 21:52:54 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
我想到了, 再加一个堆, 以查询次数作为比较基准
2023-12-06 21:49:21 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
MC 使用最小四叉堆高效地维护了过期时间, 但是只实现了 LRU, 命中率方面不如 LFU
2023-12-06 21:43:23 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@matrix1010 可以简单说下 Theine 是怎么维护过期时间和 LFU 吗?
2023-12-06 21:08:05 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@matrix1010 swiss table 的 gc 压力相比内置 map 怎么样?
2023-12-06 10:57:12 +08:00
回复了 steelshadow39 创建的主题 Java 讨论 Java 相比其他编程语言(c++, go, rust 等)的缺点
说一下 springboot ,依赖注入自动化程度很高,但是,一旦出现问题就难以排查,而且官方文档稀巴烂
2023-11-29 17:15:17 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@matrix1010 otter 作者被你炸出来了
2023-11-29 12:36:40 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@maypok86 It seems to have triggered a bug in the otter, and it's slowing it down terribly.

go test -benchmem -run=^$ -bench . github.com/lxzan/memorycache/benchmark
goos: linux
goarch: amd64
pkg: github.com/lxzan/memorycache/benchmark
cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics
BenchmarkMemoryCache_Set-12 21004170 72.60 ns/op 9 B/op 0 allocs/op
BenchmarkMemoryCache_Get-12 43787251 40.11 ns/op 0 B/op 0 allocs/op
BenchmarkMemoryCache_SetAndGet-12 45939994 45.35 ns/op 0 B/op 0 allocs/op
BenchmarkRistretto_Set-12 12190314 122.2 ns/op 112 B/op 2 allocs/op
BenchmarkRistretto_Get-12 25565082 44.60 ns/op 16 B/op 1 allocs/op
BenchmarkRistretto_SetAndGet-12 11713868 97.06 ns/op 27 B/op 1 allocs/op
BenchmarkOtter_SetAndGet-12 13760 89816 ns/op 13887 B/op 0 allocs/op
PASS
ok github.com/lxzan/memorycache/benchmark 44.081s


func BenchmarkOtter_SetAndGet(b *testing.B) {
var builder, _ = otter.NewBuilder[string, int](1000)
builder.ShardCount(128)
mc, _ := builder.Build()
for i := 0; i < benchcount; i++ {
mc.SetWithTTL(benchkeys[i%benchcount], 1, time.Hour)
}

b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var i = atomic.Int64{}
for pb.Next() {
index := i.Add(1) % benchcount
if index&7 == 0 {
mc.SetWithTTL(benchkeys[index], 1, time.Hour)
} else {
mc.Get(benchkeys[index])
}
}
})
}
2023-11-29 12:23:42 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@maypok86

> I'd like some kind of answer to this, to be honest, because I've been told so much about how only memorycache can fight ristretto, but so far it's been disappointing.

MC is just an obscure library, and I'm sure hardly anyone would say that.
2023-11-29 12:14:05 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@maypok86 The heap is used to quickly remove expired elements. Redis seems to randomly check for expired elements, which is not as efficient as the heap. In fact, users don't care if a library strictly implements the LRU algorithm, all they want is a KV store with TTL.

I've updated the benchmarks. My local cachebench hit test was too much of a pain in the ass to run, so I gave up on it.

goos: linux
goarch: amd64
pkg: github.com/lxzan/memorycache/benchmark
cpu: AMD EPYC 7763 64-Core Processor
BenchmarkMemoryCache_Set-4 7657497 133.3 ns/op 27 B/op 0 allocs/op
BenchmarkMemoryCache_Get-4 23179834 58.10 ns/op 0 B/op 0 allocs/op
BenchmarkMemoryCache_SetAndGet-4 20667798 59.09 ns/op 0 B/op 0 allocs/op
BenchmarkRistretto_Set-4 7739505 321.4 ns/op 135 B/op 2 allocs/op
BenchmarkRistretto_Get-4 12482400 97.67 ns/op 18 B/op 1 allocs/op
BenchmarkRistretto_SetAndGet-4 7265832 140.4 ns/op 31 B/op 1 allocs/op
PASS
ok github.com/lxzan/memorycache/benchmark 31.137s
2023-11-28 18:51:54 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@maypok86 It's stupid to try and convince people tirelessly. I don't see a problem with using indexed priority queues to implement memory caching with TTL, MC works well in my company's projects. I also don't see a problem with benchmarking based on random strings, redis keys often contain data ids. In MC, if you only use GetWithTTL and SetWithTTL, it's just LRU.
2023-11-28 17:23:19 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
2023-11-28 09:17:49 +08:00
回复了 Nazz 创建的主题 Go 编程语言 memorycache v1.1.5 update: 写入速度达到 Ristretto 五倍
@maypok86 The only competitor to MemoryCache (MC) is Ristretto, neither of which is GC optimized. GC optimization is not all positive gain, Codec overhead is not small. MC seeks to replace Redis in light-use scenarios, where indexed priority queues are the best data structure, simple and efficient.
2023-11-21 12:23:21 +08:00
回复了 Nazz 创建的主题 分享创造 太开心了,我的开源项目被阮一峰老师周刊收录 !
@nullcache 是土播鼠就行了
1 ... 8  9  10  11  12  13  14  15  16  17 ... 46  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2723 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 19ms · UTC 12:28 · PVG 20:28 · LAX 04:28 · JFK 07:28
Developed with CodeLauncher
♥ Do have faith in what you're doing.