News for hackers. Stuff that matters.
Re:Faster – Fast key-value store from Microsoft Research by int_19h on Friday August 17, 2018 @08:51PM (#17786325)
What kind of different strategies did you have in mind? So far as I know, P/Invoke already tries to be as low overhead as possible - e.g. primitive types and blittable structs are just passed as is, with no conversions. The recently added Span<T> is also special-cased for P/Invoke.
Re:Faster – Fast key-value store from Microsoft Research by chrisseaton on Friday August 17, 2018 @09:51PM (#17786485)
> So far as I know, P/Invoke already tries to be as low overhead as possible

As low as possible maybe, but there's lots of limiting factors with P/Invoke, such as:

- They are not inlined

- Registers need to be saved pessimistically

- The state at the point of the call is visible to observers outside of code the compiler controls so options for scheduling are constrained

- Objects need to be materialised

- All parameter values need to be available even if they aren't actually used

- Objects passed have to be pinned or given an indirect handle

- The caller has to be in a safepoint so GC can keep running

- The compiler has to juggle things into place for the C ABI, where it may normally lay things out differently

- etc

Going through a P/Invoke call is a whole inconvenient circus compared to an intrinsic.