-
Notifications
You must be signed in to change notification settings - Fork 198
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
update log to pingcap/log #217
Conversation
@kennytm PTAL again |
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.
Rest LGTM
Co-Authored-By: WangXiangUSTC <xiang13225080@163.com>
Co-Authored-By: WangXiangUSTC <xiang13225080@163.com>
Co-Authored-By: WangXiangUSTC <xiang13225080@163.com>
This reverts commit 839a37c.
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.
LGTM
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.
rest LGTM
pkg/diff/diff.go
Outdated
@@ -583,7 +584,7 @@ func getChunkRows(ctx context.Context, db *sql.DB, schema, table string, tableIn | |||
query := fmt.Sprintf("SELECT /*!40001 SQL_NO_CACHE */ %s FROM `%s`.`%s` WHERE %s ORDER BY %s%s", | |||
columns, schema, table, where, strings.Join(orderKeys, ","), collation) | |||
|
|||
log.Debugf("select data by sql %s, args: %v", query, args) | |||
log.Debug("select data", zap.String("sql", query), zap.Any("args", args)) |
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.
replace zap.Any
with zap.Reflect
?
same in tidb-binlog/driver/example/mysql/mysql.go L91.
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.
https://godoc.org/go.uber.org/zap#Reflect
in the document, have a word Outside tests, Any is always a better choice
, should we replace Any
to Reflect
? @kennytm
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.
I think this doc can be exchanged to something like
Reflect is always a better choice
😬
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.
but it's relatively slow and allocation-heavy
, seems not suggest
😬
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.
- If the type is
interface{}
,Any
is indeed better thanReflect
since it could fallback to faster methods if it turns out to be a string/int/etc. Howeverargs
is an[]interface{}
. - When you know none of the predefined methods applies,
Reflect
is a better choice thanAny
, sinceAny
will eventually give up and callReflect
anyway. - Every other method is a better choice than both
Any
andReflect
. - You could implement ArrayMarshaler to use
zap.Array
, for instance.
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.
yeh. the problem here is args []interface{}
.
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.
I do a bench mark test for []interface{}, reflect is a little better than any
BenchmarkAnyLog-4 500000 15240 ns/op
BenchmarkReflectLog-4 500000 15520 ns/op
Already changed, PTAL again
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.
LGTM
What problem does this PR solve?
update log to pingcap/log
What is changed and how it works?
update log pkg
Check List
Tests
Related changes