Use forwarders to avoid double indirection and have better performance
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
In module definitions file there's such syntax:
EXPORTS
func2=other_module.func1
They add one-time complication for loader at DLL load time, but then they optimize away unnecessary indirect call: import address table entry of caller directly points to final implementation, rather than pointing to proxy module and having another indirect all.
Some trivial fast on fast path synchronization functions that are potentially on critical path could benefit
https://github.com/microsoft/STL/blob/852a3085906108045a3951064baaf4952f596e9e/stl/src/cthread.cpp#L97-L99
Even more with XP compatibility break, when InitOnce... stuff will be called statically.
Still open questions:
- Safety of this optimization. I'm a bit concerned about unloading module that is forwarder target. It will be not a problem for
Kernel32.dll, which does not ever unload, likely to be no problem if module is imported normally as well, but generic case is still a concern, so need to figure out limitations - Using .def files, does is cost start using def files everywhere (as a possible #613 resolution), or maybe mix def files and __declspec(dllexport)
- Need to be careful with signature and calling conventions. This way likely to be ABI breaking to tune types and calling conventions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the cited fast-path synchronization code in stl/src/cthread.cpp and stl/src/sharedmutex.cpp, then read the linked Microsoft DLL export-forwarder documentation. Investigate forwarder safety during module unloading, the use of .def files versus __declspec(dllexport), and ABI or calling-convention constraints. Done requires an agreed scope and documented limitations before changing the exports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100