-
Notifications
You must be signed in to change notification settings - Fork 255
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
优化 性能 #626
优化 性能 #626
Conversation
transforms/ip/ip.go
Outdated
keysLatitude []string | ||
keysLongitude []string | ||
keysDistrictCode []string | ||
stats StatsInfo |
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.
这部分为了性能的字段建议单独放一起(空行分隔),然后加个注释简单说一下方便以后维护的人
transforms/ip/ip_test.go
Outdated
@@ -16,6 +16,7 @@ func TestTransformer(t *testing.T) { | |||
Key: "ip", | |||
DataPath: "./test_data/17monipdb.dat", | |||
} | |||
ipt.Init() |
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.
assert.Nil(t, ipt.Init())
下同
transforms/ip/ip_test.go
Outdated
//}, | ||
//{ | ||
// "ip2": "183.251.28.250", | ||
//}, |
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.
这里注释掉的如果是不用的话,直接删了吧,后来的维护会很迷惑又不敢乱动
utils/models/utils.go
Outdated
// 2. 首字符为非法字符时,去掉首字符(例如,如果字符串全为非法字符,则转换后为空) | ||
// 3. 非首字符并且为非法字符时,使用 "_" 替代非法字符 | ||
func PandoraKey(key string) (string, bool) { | ||
func CheckPandoraKey(key string) bool { |
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.
这个函数补一下是做什么用的说明吧
utils/models/utils.go
Outdated
} | ||
|
||
/* | ||
//1000000 1584 ns/op 32 B/op 2 allocs/op |
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.
留个注释,就说如果确认新版有性能和内存上的优化的话,就可以删掉了。或者 git 本来就有历史,直接删了也能找回的
utils/models/utils_test.go
Outdated
func BenchmarkCheckPandoraKey(b *testing.B) { | ||
b.ReportAllocs() | ||
testKeys := []string{"@timestamp", ".dot", "percent%100", "^^^^^^^^^^", "timestamp", "aaa"} | ||
//testKeys := []string{"timestamp", "aaa"} |
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.
同上
utils/models/utils_test.go
Outdated
@@ -651,6 +672,42 @@ func BenchmarkDeepConvertKey(b *testing.B) { | |||
"percent%100": 100, | |||
"^^^^^^^^^^": "mytest", | |||
}, | |||
{ | |||
"timestamp": "2018-07-18T10:17:36.549054846+08:00", | |||
//"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
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.
同上
}, | ||
{ | ||
"timestamp": "2018-07-18T10:17:36.549054846+08:00", | ||
//"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
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.
同上
}, | ||
{ | ||
"timestamp": "2018-07-18T10:17:36.549054846+08:00", | ||
//"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
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.
同上
utils/models/utils.go
Outdated
@@ -780,11 +786,11 @@ func PandoraKey(key string) (string, bool) { | |||
valid = false | |||
} | |||
if valid { | |||
return key, true | |||
return []byte(key), true |
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.
来回转换 bytes 到 string 从逻辑上来讲其实反而多分配了一次 []byte 吧?上层也是仍旧要转回 string 类型而不能直接使用 []byte
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.
我觉得返回 *string 是可以考虑的?
sender/fault_tolerant.go
Outdated
@@ -74,6 +76,7 @@ func NewFtSender(ftSender Sender, conf conf.MapConf, ftSaveLogPath string) (*FtS | |||
writeLimit, _ := conf.GetIntOr(KeyFtWriteLimit, defaultWriteLimit) | |||
strategy, _ := conf.GetStringOr(KeyFtStrategy, KeyFtStrategyBackupOnly) | |||
longDataDiscard, _ := conf.GetBoolOr(KeyFtLongDataDiscard, false) | |||
sendType, _ := conf.GetStringOr(KeySenderType, "") //此处不会没有SenderType,在调用NewFtSender时已经检查 |
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.
s/sendType/senderType/
sender/fault_tolerant.go
Outdated
@@ -91,6 +94,7 @@ func NewFtSender(ftSender Sender, conf conf.MapConf, ftSaveLogPath string) (*FtS | |||
memoryChannel: memoryChannel, | |||
memoryChannelSize: memoryChannelSize, | |||
longDataDiscard: longDataDiscard, | |||
innerSendType: sendType, |
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.
s/innerSendType/innerSenderType/
LGTM |
Fixes [issue number]
Changes
Reviewers
Wiki Changes
Checklist