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

update log to pingcap/log #217

Merged
merged 21 commits into from
Mar 20, 2019
Merged

Conversation

WangXiangUSTC
Copy link
Contributor

What problem does this PR solve?

update log to pingcap/log

What is changed and how it works?

update log pkg

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

@WangXiangUSTC
Copy link
Contributor Author

@kennytm PTAL again

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

Rest LGTM

kennytm and others added 11 commits March 18, 2019 23:40
Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@csuzhangxc csuzhangxc left a 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))
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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

😬

Copy link
Contributor Author

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
😬

Copy link
Contributor

Choose a reason for hiding this comment

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

@WangXiangUSTC @csuzhangxc

  1. If the type is interface{}, Any is indeed better than Reflect since it could fallback to faster methods if it turns out to be a string/int/etc. However args is an []interface{}.
  2. When you know none of the predefined methods applies, Reflect is a better choice than Any, since Any will eventually give up and call Reflect anyway.
  3. Every other method is a better choice than both Any and Reflect.
  4. You could implement ArrayMarshaler to use zap.Array, for instance.

Copy link
Member

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{}.

Copy link
Contributor Author

@WangXiangUSTC WangXiangUSTC Mar 20, 2019

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

Copy link
Member

@csuzhangxc csuzhangxc left a comment

Choose a reason for hiding this comment

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

LGTM

@WangXiangUSTC WangXiangUSTC merged commit b971f53 into pingcap:master Mar 20, 2019
@WangXiangUSTC WangXiangUSTC deleted the xiang/log branch March 20, 2019 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants