-
Notifications
You must be signed in to change notification settings - Fork 7
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
Create a logging policy using sync/atomic load and store value #153
Conversation
Signed-off-by: codegold79 <codegold79@gmail.com>
a2ce99b
to
09232ff
Compare
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
@daved I've made the these updates:
|
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
@daved In this PR, I'm using the sync/atomic atomic.Value load/store methods. Please compare with the other two PRs I posted:
My next goal is to put the three branches through benchmark testing to compare their performance. |
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Benchmark test resultsRange: 1.204s - 1.668s TEST A 10000 135192 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 1.358s TEST B 10000 119121 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 1.204s TEST C 10000 166115 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 1.668s TEST D 10000 127507 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 1.284s TEST E 10000 139454 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 1.413s |
Signed-off-by: codegold79 <codegold79@gmail.com>
After improving benchmark test, I ran test again: 16580 85695 ns/op |
Signed-off-by: codegold79 <codegold79@gmail.com>
Sync atomic load and store using b.RunParallelResults$ go test -bench=. $ go test -bench=. $ go test -bench=. $ go test -bench=. ConclusionSync atomic store and load of values seems to beat out mutex locks and unlocks in parallel benchmark tests (PR #162) for the dbg package. I'm recommending this PR for merge. |
Signed-off-by: codegold79 <codegold79@gmail.com>
During our last meeting, @daved found that this debug logger was racy. I fixed it so that race detector did not find a race when I ran goos: linux
goarch: amd64
pkg: github.com/OpenEugene/openboard/back/internal/dbg
cpu: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
BenchmarkDbgUse-4 4487584 246.4 ns/op
BenchmarkDbgUseNil-4 4612100 248.8 ns/op
BenchmarkDbgSetAndUse-4 4194343 249.5 ns/op
BenchmarkDbgSetAndUseNil-4 22563385 47.44 ns/op
PASS
ok github.com/OpenEugene/openboard/back/internal/dbg 5.301s The performance using sync atomic still beats the mutex version in PR #162. I maintain my recommendation that this is the dbg logger version that gets merged. |
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Signed-off-by: codegold79 <codegold79@gmail.com>
Added ability to log information to stdout, errors to stderr, and uses package-level variable debug logger for debugging.
Closes #123