-
Notifications
You must be signed in to change notification settings - Fork 2
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
windows: dynamically adjust the buffer size #5
Conversation
} | ||
go w.readEvents() | ||
return w, nil | ||
} | ||
|
||
func (w *Watcher) SetBufferSize(bufSize int) { |
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.
Where does this get called?
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 plan to call it from the tilt code!
e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0], | ||
uint32(unsafe.Sizeof(watch.buf)), w.recursive, mask, nil, &watch.ov, 0) | ||
|
||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&watch.buf)) |
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.
Not sure what's going on here 😅
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.
In Go, a slice is implemented as
- a pointer to some memory
- a length field
- a capacity field
https://golang.org/pkg/reflect/#SliceHeader
The windows syscall is all C. It needs a pointer to memory. So we unpack the slice, and pull the memory pointer out.
it's conceptually not that hard, but Go REALLY doesn't want you to do this (because it starts to mess with the Go garbage collector), so the syntax is pretty awkward
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.
ahh got it, that makes sense!
Hello @jazzdan,
Please review the following commits I made in branch nicks/bufsize:
56f2b1e (2020-07-27 15:05:09 -0400)
windows: dynamically adjust the buffer size
Code review reminders, by giving a LGTM you attest that: