nuke/monotoniic: reset's behavior and a little bit of improvements #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@ortuman Hi!
there is a little bit of improvements for current version of the nuke:
alignOffset
without iterations;for
s;the most important changes is related to behavior of the reset method.
I guess the reset method should always reset memory and release it optionally.
in general I would like to see two separate methods like (suggestion):
Reset()
resets memory;Free()
releases memory.as an idea in the air, we could have only one method
Free()
(like on Go's Arena) that under the hood always resets and releases memory.Benchmark results for the nuke latest version:
go test -bench=. ./... goos: darwin goarch: amd64 pkg: github.com/ortuman/nuke cpu: Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz BenchmarkRuntimeNewObject/100-8 914125 1297 ns/op 800 B/op 100 allocs/op BenchmarkRuntimeNewObject/1000-8 87066 13075 ns/op 8000 B/op 1000 allocs/op BenchmarkRuntimeNewObject/10000-8 8016 130695 ns/op 80000 B/op 10000 allocs/op BenchmarkRuntimeNewObject/100000-8 878 1288538 ns/op 800009 B/op 100000 allocs/op BenchmarkMonotonicArenaNewObject/100-8 33520 35639 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/1000-8 24528 49212 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/10000-8 6745 163495 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/100000-8 846 1353877 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/100-8 32326 36768 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/1000-8 21222 53665 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/10000-8 4714 233151 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/100000-8 598 1939938 ns/op 0 B/op 0 allocs/op BenchmarkRuntimeMakeSlice/100-8 36321 33419 ns/op 204800 B/op 100 allocs/op BenchmarkRuntimeMakeSlice/1000-8 3405 330008 ns/op 2048009 B/op 1000 allocs/op BenchmarkRuntimeMakeSlice/10000-8 362 3354655 ns/op 20480100 B/op 10001 allocs/op BenchmarkRuntimeMakeSlice/100000-8 31 35878034 ns/op 204801102 B/op 100011 allocs/op BenchmarkMonotonicArenaMakeSlice/100-8 27572 40248 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/1000-8 23138 48749 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/10000-8 1066 1023822 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/100000-8 26 43787002 ns/op 137691202 B/op 67232 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/100-8 28334 37244 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/1000-8 20376 55866 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/10000-8 1039 1123206 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/100000-8 25 48233981 ns/op 137691197 B/op 67232 allocs/op PASS ok github.com/ortuman/nuke 36.701s
Benchmark results for this pr:
go test -bench=. ./... goos: darwin goarch: amd64 pkg: github.com/ortuman/nuke cpu: Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz BenchmarkRuntimeNewObject/100-8 936972 1286 ns/op 800 B/op 100 allocs/op BenchmarkRuntimeNewObject/1000-8 91796 13433 ns/op 8000 B/op 1000 allocs/op BenchmarkRuntimeNewObject/10000-8 8335 131346 ns/op 80000 B/op 10000 allocs/op BenchmarkRuntimeNewObject/100000-8 890 1266103 ns/op 800005 B/op 100000 allocs/op BenchmarkRuntimeNewObject/1000000-8 80 12671721 ns/op 8000057 B/op 1000000 allocs/op BenchmarkMonotonicArenaNewObject/100-8 34165 35619 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/1000-8 24819 46491 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/10000-8 7020 159810 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/100000-8 918 1272404 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaNewObject/1000000-8 54 21980538 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/100-8 32769 36106 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/1000-8 22920 51180 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/10000-8 5166 207716 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/100000-8 664 1762064 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaNewObject/1000000-8 45 25286030 ns/op 0 B/op 0 allocs/op BenchmarkRuntimeMakeSlice/100-8 36538 32732 ns/op 204801 B/op 100 allocs/op BenchmarkRuntimeMakeSlice/1000-8 3331 330120 ns/op 2048009 B/op 1000 allocs/op BenchmarkRuntimeMakeSlice/10000-8 352 3387211 ns/op 20480104 B/op 10001 allocs/op BenchmarkRuntimeMakeSlice/100000-8 34 33814642 ns/op 204801126 B/op 100011 allocs/op BenchmarkRuntimeMakeSlice/1000000-8 4 327812672 ns/op 2048010200 B/op 1000106 allocs/op BenchmarkMonotonicArenaMakeSlice/100-8 30214 38373 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/1000-8 24309 48698 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/10000-8 991 1085629 ns/op 0 B/op 0 allocs/op BenchmarkMonotonicArenaMakeSlice/100000-8 31 35497399 ns/op 137691185 B/op 67232 allocs/op BenchmarkMonotonicArenaMakeSlice/1000000-8 3 416722326 ns/op 1980892256 B/op 967243 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/100-8 31250 37739 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/1000-8 21745 54868 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/10000-8 1105 1017490 ns/op 0 B/op 0 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/100000-8 30 40167859 ns/op 137691193 B/op 67232 allocs/op BenchmarkConcurrentMonotonicArenaMakeSlice/1000000-8 2 544447913 ns/op 1980891952 B/op 967240 allocs/op PASS ok github.com/ortuman/nuke 50.360s
Benchmarks above are the best of what I can get on my machine.
if you are interested in some specific change I can split this pr.