➜ bigcache git:(master) go test -bench=. -benchmem -benchtime=4s ./... 2020/03/18 01:16:41 Allocated new queue in 123.43µs; Capacity: 585000 2020/03/18 01:16:41 Allocated new queue in 401.61µs; Capacity: 1170000 2020/03/18 01:16:41 Allocated new queue in 290ns; Capacity: 94 goos: linux goarch: amd64 pkg: github.com/allegro/bigcache/v2 BenchmarkWriteToCacheWith1Shard-4 2987080 1637 ns/op 591 B/op 3 allocs/op BenchmarkWriteToLimitedCacheWithSmallInitSizeAnd1Shard-4 5463650 785 ns/op 41 B/op 3 allocs/op BenchmarkWriteToUnlimitedCacheWithSmallInitSizeAnd1Shard-4 fatal error: runtime: out of memory runtime stack: runtime.throw(0x56a58a, 0x16) /home/centos/go/src/runtime/panic.go:774 +0x72 runtime.sysMap(0xc258000000, 0xc8000000, 0x691298) /home/centos/go/src/runtime/mem_linux.go:169 +0xc5 runtime.(*mheap).sysAlloc(0x678480, 0xc8000000, 0x3800016a51, 0xc000041e00) /home/centos/go/src/runtime/malloc.go:701 +0x1cd runtime.(*mheap).grow(0x678480, 0x64000, 0xffffffff) /home/centos/go/src/runtime/mheap.go:1252 +0x42 runtime.(*mheap).allocSpanLocked(0x678480, 0x64000, 0x6912a8, 0x41c8f5) /home/centos/go/src/runtime/mheap.go:1163 +0x291 runtime.(*mheap).alloc_m(0x678480, 0x64000, 0x7fc497110101, 0x7fc49711bfa8) /home/centos/go/src/runtime/mheap.go:1015 +0xc2 runtime.(*mheap).alloc.func1() /home/centos/go/src/runtime/mheap.go:1086 +0x4c runtime.(*mheap).alloc(0x678480, 0x64000, 0xc000010101, 0x7fc49711bfa8) /home/centos/go/src/runtime/mheap.go:1085 +0x8a runtime.largeAlloc(0xc8000000, 0x101, 0xc000090b20) /home/centos/go/src/runtime/malloc.go:1138 +0x97 runtime.mallocgc.func1() /home/centos/go/src/runtime/malloc.go:1033 +0x46 runtime.systemstack(0x0) /home/centos/go/src/runtime/asm_amd64.s:370 +0x66 runtime.mstart() /home/centos/go/src/runtime/proc.go:1146 goroutine 232 [running]: runtime.systemstack_switch() /home/centos/go/src/runtime/asm_amd64.s:330 fp=0xc000090ab0 sp=0xc000090aa8 pc=0x459ab0 runtime.mallocgc(0xc8000000, 0x52d1a0, 0x324fce01, 0x25cad3853bbec) /home/centos/go/src/runtime/malloc.go:1032 +0x895 fp=0xc000090b50 sp=0xc000090ab0 pc=0x40c125 runtime.makeslice(0x52d1a0, 0xc8000000, 0xc8000000, 0x20301900000000) /home/centos/go/src/runtime/slice.go:49 +0x6c fp=0xc000090b80 sp=0xc000090b50 pc=0x442c6c github.com/allegro/bigcache/v2/queue.(*BytesQueue).allocateAdditionalMemory(0xc0157a0128, 0x421) /home/centos/gopath/src/github.com/allegro/bigcache/queue/bytes_queue.go:103 +0xbd fp=0xc000090c10 sp=0xc000090b80 pc=0x4fd75d github.com/allegro/bigcache/v2/queue.(*BytesQueue).Push(0xc0157a0128, 0xc0000ac900, 0x41d, 0x41d, 0xc0000b6400, 0x400, 0x400) /home/centos/gopath/src/github.com/allegro/bigcache/queue/bytes_queue.go:81 +0xda fp=0xc000090c50 sp=0xc000090c10 pc=0x4fd61a github.com/allegro/bigcache/v2.(*cacheShard).set(0xc0157a0120, 0xc064eca7c0, 0xb, 0x84b5b6a195780c0b, 0xc0000b6400, 0x400, 0x400, 0xc064eca7c0, 0xc000166340) /home/centos/gopath/src/github.com/allegro/bigcache/shard.go:140 +0x1b2 fp=0xc000090d00 sp=0xc000090c50 pc=0x503342 github.com/allegro/bigcache/v2.(*BigCache).Set(0xc000166270, 0xc064eca7c0, 0xb, 0xc0000b6400, 0x400, 0x400, 0xb, 0x0) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:134 +0xac fp=0xc000090d58 sp=0xc000090d00 pc=0x4fff2c github.com/allegro/bigcache/v2.BenchmarkWriteToUnlimitedCacheWithSmallInitSizeAnd1Shard(0xc0aca4c1c0) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache_bench_test.go:44 +0x1f5 fp=0xc000090ec0 sp=0xc000090d58 pc=0x505a65 testing.(*B).runN(0xc0aca4c1c0, 0x1ee99b) /home/centos/go/src/testing/benchmark.go:190 +0xcc fp=0xc000090f38 sp=0xc000090ec0 pc=0x4b9edc testing.(*B).launch(0xc0aca4c1c0) /home/centos/go/src/testing/benchmark.go:320 +0x10c fp=0xc000090fd8 sp=0xc000090f38 pc=0x4ba57c runtime.goexit() /home/centos/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000090fe0 sp=0xc000090fd8 pc=0x45ba01 created by testing.(*B).doBench /home/centos/go/src/testing/benchmark.go:275 +0x55 goroutine 1 [chan receive]: testing.(*B).doBench(0xc0aca4c1c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /home/centos/go/src/testing/benchmark.go:276 +0x73 testing.(*benchContext).processBench(0xc064954860, 0xc0aca4c1c0) /home/centos/go/src/testing/benchmark.go:563 +0x2da testing.(*B).run(0xc0aca4c1c0) /home/centos/go/src/testing/benchmark.go:267 +0x63 testing.(*B).Run(0xc0aca4c000, 0x56ff1d, 0x38, 0x570ad0, 0x4b9b00) /home/centos/go/src/testing/benchmark.go:631 +0x36a testing.runBenchmarks.func1(0xc0aca4c000) /home/centos/go/src/testing/benchmark.go:532 +0x78 testing.(*B).runN(0xc0aca4c000, 0x1) /home/centos/go/src/testing/benchmark.go:190 +0xcc testing.runBenchmarks(0x56c333, 0x1e, 0xc064954840, 0x66fe00, 0xb, 0xb, 0x40bba6) /home/centos/go/src/testing/benchmark.go:538 +0x39a testing.(*M).Run(0xc0000be000, 0x0) /home/centos/go/src/testing/testing.go:1123 +0x439 main.main() _testmain.go:152 +0x135 goroutine 181 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x1, 0x12a05f200, 0x3b9aca00, 0x927c0, 0x1f4, 0x101, 0x592b20, 0x68ec88, 0x1, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 180 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x12a05f200, 0x3b9aca00, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 212 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x8bb2c97000, 0x3b9aca00, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 214 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x8bb2c97000, 0x45d964b800, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x2000, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 210 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x1, 0x12a05f200, 0x45d964b800, 0x1, 0x1, 0x100, 0x592b20, 0x68ec88, 0x1, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 197 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x12a05f200, 0x3b9aca00, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 127 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x3b9aca00, 0x3b9aca00, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 170 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0x0, 0x3b9aca00, 0x927c0, 0x1f4, 0x101, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 168 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x400, 0xdf8475800, 0x3b9aca00, 0x927c0, 0x1f4, 0x100, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f goroutine 7 [select]: github.com/allegro/bigcache/v2.newBigCache.func1(0x4, 0x3b9aca00, 0x3b9aca00, 0x1, 0x100, 0x0, 0x592b20, 0x68ec88, 0x0, 0x0, ...) /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:91 +0x146 created by github.com/allegro/bigcache/v2.newBigCache /home/centos/gopath/src/github.com/allegro/bigcache/bigcache.go:87 +0x46f exit status 2 FAIL github.com/allegro/bigcache/v2 28.967s PASS ok github.com/allegro/bigcache/v2/queue 0.006s 2020/03/18 01:17:08 Entry not found 2020/03/18 01:17:08 stored "testkey" in cache. 2020/03/18 01:17:08 empty request. 2020/03/18 01:17:08 test read error 2020/03/18 01:17:08 not found. 2020/03/18 01:17:08 stored "putKey" in cache. 2020/03/18 01:17:08 empty request. 2020/03/18 01:17:08 Entry not found 2020/03/18 01:17:08 invalidDeleteKey not found. 2020/03/18 01:17:08 entry is bigger than max shard size PASS ok github.com/allegro/bigcache/v2/server 0.227s FAIL ➜ bigcache git:(master) ➜ bigcache git:(master) ➜ bigcache git:(master) ulimit -a -t: cpu time (seconds) unlimited -f: file size (blocks) unlimited -d: data seg size (kbytes) unlimited -s: stack size (kbytes) 8192 -c: core file size (blocks) 0 -m: resident set size (kbytes) unlimited -u: processes 4096 -n: file descriptors 1024 -l: locked-in-memory size (kbytes) 64 -v: address space (kbytes) unlimited -x: file locks unlimited -i: pending signals 31110 -q: bytes in POSIX msg queues 819200 -e: max nice 0 -r: max rt priority 0 -N 15: unlimited