-
Notifications
You must be signed in to change notification settings - Fork 155
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
optimise yarahunter #89
Conversation
using fmt writes the error log to stdout, that then goes to json. which we don't want.
This changes were benchmarked by @ramanan-ravi @ibreakthecloud @gnmahanth @noboruma @akumars1 on different setups
cc: @shyam-dev |
@@ -211,6 +212,10 @@ func isExecutable(path string) bool { | |||
return fileMimetypeCheck(path, execMimeTypes) | |||
} | |||
|
|||
func BytesToString(b []byte) (s string) { |
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.
There is a reason golang calls this library unsafe !! Is there a reason we prefer this over string() or fmt.Sprintf ? @noboruma / @ibreakthecloud ??
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.
unsafe.String
is faster than using string()
, since unsafe doesnot actually copies the data but instead creates a new string header that references the same underlying data as the byte slice. The down-side of this is any changes in byte slice will result in affecting the string, which is shouldn't be any trouble in our case.
cc: @noboruma
also I think we should use -d=checkptr
flag while building if we're not already
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.
one thing I am not sure if garbage collector will free this prematurely. @noboruma
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.
There are cases where GC can prematurely release the memory, but not in that scenario because the reference we have created is not unsafe anymore, it's a regular string and this will prevent GC from collecting further
// todo