-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use uint64 intead of uint32 #236
Conversation
I like this, but we should document that this change breaks 32-bit compatibility (assuming it existed already), and this should likely be a new version. |
@cristaloleg do you want this to be a part of 3.0 since it breaks 32-bit compatibility or just cut a new release as normal? |
Well, breaking 32bit compatibility in patch/minor version is a bad thing. Better to postpone till 3.0 :( |
@janisz if you can rebase against the |
@mxplusb Done |
6ec47a5
to
e861020
Compare
Issues reported in allegro#246
Interesting, race checker adds more memory ➜ bigcache git:(fix_148) ✗ go test
2020/10/08 22:24:22 Allocated new queue in 492ns; Capacity: 88
2020/10/08 22:24:22 Allocated new queue in 5.826µs; Capacity: 256046
2020/10/08 22:24:22 Allocated new queue in 122.952µs; Capacity: 512092
2020/10/08 22:24:22 Allocated new queue in 318.934µs; Capacity: 1024184
2020/10/08 22:24:23 Allocated new queue in 267.441µs; Capacity: 585000
2020/10/08 22:24:23 Allocated new queue in 294.733µs; Capacity: 1170000
PASS
ok github.com/allegro/bigcache/v3 14.906s
➜ bigcache git:(fix_148) ✗ go test -race
signal: killed
FAIL github.com/allegro/bigcache/v3 19.155s ➜ bigcache git:(fix_148) ✗ dmesg
[44698.559338] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice,task=bigcache.test,pid=26385,uid=1000
[44698.559368] Out of memory: Killed process 26385 (bigcache.test) total-vm:31216124kB, anon-rss:19200356kB, file-rss:0kB, shmem-rss:3452kB, UID:1000 pgtables:39016kB oom_score_adj:0
[44698.973775] oom_reaper: reaped process 26385 (bigcache.test), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB ➜ bigcache git:(fix_148) ✗ go version
go version go1.15.2 linux/amd64 |
➜ bigcache git:(fix_148) ✗ go test -race -c -o test_race github.com/allegro/bigcache/v3
➜ bigcache git:(fix_148) ✗ /usr/bin/time -v ./test_race
Command terminated by signal 9
Command being timed: "./test_race"
User time (seconds): 19.79
System time (seconds): 9.03
Percent of CPU this job got: 151%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:18.97
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 18998948
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 130
Minor (reclaiming a frame) page faults: 8179180
Voluntary context switches: 2791
Involuntary context switches: 558
Swaps: 0
File system inputs: 27864
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
➜ bigcache git:(fix_148) ✗ go test -c -o test github.com/allegro/bigcache/v3
➜ bigcache git:(fix_148) ✗ /usr/bin/time -v ./test
PASS
Command being timed: "./test"
User time (seconds): 19.65
System time (seconds): 3.31
Percent of CPU this job got: 146%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:15.71
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 13417992
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 1020072
Voluntary context switches: 324544
Involuntary context switches: 640
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0 |
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
=========================================
Coverage ? 87.18%
=========================================
Files ? 15
Lines ? 640
Branches ? 0
=========================================
Hits ? 558
Misses ? 69
Partials ? 13
Continue to review full report at Codecov.
|
I'm not sure if this breaks compatibility. API is the same so on 32bits it will work as before |
Co-authored-by: Oleg Kovalov <[email protected]>
Signed-off-by: Mike Lloyd <[email protected]>
There are posibility we run into a problem of int32 overflow. To prevent this let's use uint64 everywhere. https://github.com/allegro/bigcache/blob/21e5ca5c3d539f94e8dc563350acd97c5400154f/shard.go#L138 Fixes: allegro#148
I removed 1.13 since it's failing. I need to debug why |
It's passing on my machine?
|
@cristaloleg @mxplusb PTAL |
@@ -42,7 +42,7 @@ jobs: | |||
run: | | |||
go test -race -count=1 -coverprofile=queue.coverprofile ./queue | |||
go test -race -count=1 -coverprofile=server.coverprofile ./server | |||
go test -race -count=1 -coverprofile=main.coverprofile | |||
go test -race -count=1 -coverprofile=main.coverprofile -short |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait a sec, why short?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because new test eats too much memory
https://github.com/allegro/bigcache/pull/236/files#diff-013414c814f8b4b2df17143a678bcc6726758e92f0be44d01df40e3dca9ad967R1072
@cristaloleg It looks like the 1.13.x build requirement is blocking the merge, can you remove it? |
* Add Benchmark for append * Optimize Append and halve byte copies * Optimize Append by reducing allocs * Optimize Append by reducing allocs * Reduces allocs from test construct Co-authored-by: Fabian Gärtner <[email protected]>
@cristaloleg PTAL |
I'm merging this into the v3 base so we can close out the work item so it's in 3.0. |
* Fix iterator styling issues (#247) Issues reported in #246 * fix #160 (#246) * Update to latest golang (#248) Co-authored-by: Oleg Kovalov <[email protected]> * inital prep for v3. Signed-off-by: Mike Lloyd <[email protected]> * Use uint64 intead of uint32 There are posibility we run into a problem of int32 overflow. To prevent this let's use uint64 everywhere. https://github.com/allegro/bigcache/blob/21e5ca5c3d539f94e8dc563350acd97c5400154f/shard.go#L138 Fixes: #148 * Fix CI * Do not run on 1.13 * Do not run long test * Optimze append (#249) * Add Benchmark for append * Optimize Append and halve byte copies * Optimize Append by reducing allocs * Optimize Append by reducing allocs * Reduces allocs from test construct Co-authored-by: Fabian Gärtner <[email protected]> Co-authored-by: S@P <[email protected]> Co-authored-by: Oleg Kovalov <[email protected]> Co-authored-by: Mike Lloyd <[email protected]> Co-authored-by: Fabianexe <[email protected]> Co-authored-by: Fabian Gärtner <[email protected]>
There are posibility we run into a problem of int32 overflow.
To prevent this let's use uint64 everywhere.
bigcache/shard.go
Line 138 in 21e5ca5
Fixes: #148