Skip to content
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

Added processDebugger component #4288

Merged
merged 17 commits into from
Sep 14, 2022
Merged

Conversation

iulianpascalau
Copy link
Contributor

  • added processDebugger + integration

@ssd04 ssd04 self-requested a review July 14, 2022 13:35
Comment on lines +96 to +97
processDebugger, err := createDisabledProcessDebugger()
if err != nil {
Copy link
Contributor

@ssd04 ssd04 Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to use a disabled instance, or this is just at first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always use a disable instance in order to prevent all checks for nils. This is the power of the polymorhism :)

@miiu96 miiu96 self-requested a review July 15, 2022 12:11
type ProcessDebugConfig struct {
Enabled bool
LogLevelChanger string
GoRoutinesDump bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables with the same type should stay together (optime memory usage)
GoRoutinesDump can be moved near Enabled field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"github.com/ElrondNetwork/elrond-go/config"
)

const minAcceptedValue = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can group the consts together

const (
	minAcceptedValue = 1
	buffSize         = 100 * 1024 * 1024 // 100MB
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -800,6 +800,11 @@
[Debug.EpochStart]
GoRoutineAnalyserEnabled = true
ProcessDataTrieOnCommitEpoch = true
[Debug.Process]
Enabled = true
LogLevelChanger = "*:DEBUG,p2p:TRACE,debug:DEBUG,process:TRACE,intercept:TRACE"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogLevelChanger I think this can be renamed
---> DebuggingLogLevel or NewLogLevel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
d.logChangeHandler = func() {
errSetLogLevel := logger.SetLogLevel(d.logLevel)
log.LogIfError(errSetLogLevel)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.LogIfError(errSetLogLevel, "d.logChangeHandle: cannot change log level") -- in order to know where the error appears

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored


ctx, cancel := context.WithCancel(context.Background())
d.cancel = cancel
d.goRoutinesDumpHandler = func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this function have to be declared?
it can be expressed as a normal function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was done like this in order to thoroughly test the component (in tests, I swapped these function pointers with testing functions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created method

numBytes := runtime.Stack(buff, true)
log.Debug(string(buff[:numBytes]))
}
d.logChangeHandler = func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, logChangeHandler can be declared

func (debugger *processDebugger) logChangeHandler() {
	errSetLogLevel := logger.SetLogLevel(debugger.logLevel)
	log.LogIfError(errSetLogLevel)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, will dump the anonymous functions usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -25,7 +27,7 @@ type processDebugger struct {
goRoutinesDumpHandler func()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goRoutinesDumpHandler and logChangeHandler can be removed and call the functions directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, can not properly test the component otherwise

miiu96
miiu96 previously approved these changes Jul 15, 2022
ssd04
ssd04 previously approved these changes Jul 15, 2022
@iulianpascalau iulianpascalau changed the base branch from rc/2022-july to rc/v1.4.0 September 9, 2022 05:56
@iulianpascalau iulianpascalau dismissed stale reviews from ssd04 and miiu96 September 9, 2022 05:56

The base branch was changed.

# Conflicts:
#	factory/interface.go
#	process/block/baseProcess.go
#	process/block/metablock.go
#	process/block/preprocess/gasComputation.go
#	process/block/shardblock.go
#	process/errors.go
#	process/interface.go
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2022

Codecov Report

Base: 73.84% // Head: 73.85% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (66e6f53) compared to base (ff936b2).
Patch coverage: 81.95% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##           rc/v1.4.0    #4288      +/-   ##
=============================================
+ Coverage      73.84%   73.85%   +0.01%     
=============================================
  Files            689      692       +3     
  Lines          88127    88257     +130     
=============================================
+ Hits           65075    65186     +111     
- Misses         18140    18156      +16     
- Partials        4912     4915       +3     
Impacted Files Coverage Δ
factory/blockProcessorCreator.go 35.90% <36.36%> (+<0.01%) ⬆️
process/block/metablock.go 60.50% <60.00%> (-0.01%) ⬇️
process/block/shardblock.go 66.64% <60.00%> (-0.03%) ⬇️
process/block/baseProcess.go 73.11% <75.00%> (+0.22%) ⬆️
debug/process/debugger.go 90.12% <90.12%> (ø)
debug/factory/processDebuggerFactory.go 100.00% <100.00%> (ø)
debug/process/disabledDebugger.go 100.00% <100.00%> (ø)
p2p/libp2p/netMessenger.go 80.28% <0.00%> (+0.26%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System test passed.

@iulianpascalau iulianpascalau merged commit 326726a into rc/v1.4.0 Sep 14, 2022
@iulianpascalau iulianpascalau deleted the process-debug-handler branch September 14, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants