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

Imp: remove useless time format #1955

Merged
merged 1 commit into from
Jul 8, 2022
Merged

Conversation

CoolIceV
Copy link
Contributor

@CoolIceV CoolIceV commented Jul 6, 2022

What this PR does:
Whether this log is output or not, the date will be formatted and cost a lot time, now it will be output without formatting as 2022-07-06 19:37:39.4692053 +0800 CST m=+0.775520901

Which issue(s) this PR fixes:
Fixes #1954

You should pay attention to items below to ensure your pr passes our ci test
We do not merge pr with ci tests failed

  • All ut passed (run 'go test ./...' in project root)
  • After go-fmt ed , run 'go fmt project' using goland.
  • Golangci-lint passed, run 'sudo golangci-lint run' in project root.
  • After import formatted, (using imports-formatter to run 'imports-formatter .' in project root, to format your import blocks, mentioned in CONTRIBUTING.md above)
  • Your new-created file needs to have apache license at the top, like other existed file does.
  • All integration test passed. You can run integration test locally (with docker env). Clone our dubbo-go-samples project and replace the go.mod to your dubbo-go, and run 'sudo sh start_integration_test.sh' at root of samples project root. (M1 Slice is not Support)

@justxuewei
Copy link
Member

justxuewei commented Jul 6, 2022

Hi Yepeng, thanks for your contribution, I wonder how much the performance can be improved if the String() is removed? It seems that parsing the time takes a lots of time in the flame graph you posted on the issue #1954.

@CoolIceV
Copy link
Contributor Author

CoolIceV commented Jul 6, 2022

I tested it roughly. When the QPS was high, there was about a ten or so milliseconds' improvement, but when the QPS was low, there didn't seem to be much optimization.

Copy link
Member

@binbin0325 binbin0325 left a comment

Choose a reason for hiding this comment

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

%s print time, eventually the String() function is called as well。 If must print the time, you can make a special note。
this should not matter in debug print log mode

@CoolIceV
Copy link
Contributor Author

CoolIceV commented Jul 6, 2022

%s print time, eventually the String() function is called as well。 If must print the time, you can make a special note。 this should not matter in debug print log mode

I've now just delayed the String() call, meaning that if I don't want to print the log, I won't call the String() method, the original code would have called it whether or not the log was printed.
Original:
image
Modified:
image

Copy link
Contributor

@zhaoyunxing92 zhaoyunxing92 left a comment

Choose a reason for hiding this comment

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

如果只是打印当前时间的话是不是用log的时间就可以了

@CoolIceV
Copy link
Contributor Author

CoolIceV commented Jul 8, 2022

如果只是打印当前时间的话是不是用log的时间就可以了

这个需要看log中的时间与所想要打印的时间会有多大的差距,这个本来就是debug用的,我觉得现在这样处理就可以,不用太纠结这个

@AlexStocks AlexStocks merged commit 1abbc2e into apache:3.0 Jul 8, 2022
@CoolIceV CoolIceV deleted the adaptive-service branch August 7, 2022 09:14
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