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

x/sys/windows: Consider exporting kernel32 *LazyDLL #15702

Closed
taruti opened this issue May 16, 2016 · 4 comments
Closed

x/sys/windows: Consider exporting kernel32 *LazyDLL #15702

taruti opened this issue May 16, 2016 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@taruti
Copy link
Contributor

taruti commented May 16, 2016

Currently all libraries needing more procedures load the libraries by hand using either syscall or x/sys/windows. The most common DLL by a large margin used in this fashion appears to be kernel32.dll.

This means that in larger applications there are half-a-dozen libraries loading kernel32.dll. They could use a shared copy since *LazyDLL is safe for concurrent use.

Exporting:

var ModKernel32DLL = NewLazySystemDLL("kernel32.dll")

from x/sys/windows would enable sharing this for applications.

x/sys/windows loads a copy of kernel32.dll in any case (modkernel32).

If needed I can write a proposal or a patch.

@alexbrainman
Copy link
Member

I don't see what the benefit here. Is something going to be faster? Less lines of code? What? Please explain. Thank you.

Alex

@bradfitz bradfitz added this to the Unplanned milestone May 17, 2016
@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 17, 2016
@taruti
Copy link
Contributor Author

taruti commented May 17, 2016

@alexbrainman
It would call LoadLibrary once for sys/x/windows instead once for each library needing functions from kernel32.dll.

Underneath Windows does reference counting of the DLLs loaded so calling LoadLibrary("kernel32.dll") multiple times results in only a single copy of the library in the address space. So the saving is a little bit of memory and few less syscalls.

@alexbrainman
Copy link
Member

It would call LoadLibrary once for sys/x/windows instead once for each library needing functions from kernel32.dll.

I don't see any benefit here. It is just few more calls into LoadLibrary. It is not slow code. And average app calls LoadLibrary just couple of times. And since I use $GOROOT/src/syscall/mksyscall_windows.go to generate my syscalls, I don't even have to write that code.

It is not worth the trouble.

Alex

@taruti
Copy link
Contributor Author

taruti commented May 18, 2016

Ok, thanks for considering it.

@taruti taruti closed this as completed May 18, 2016
@golang golang locked and limited conversation to collaborators May 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants