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

.NET 7 Improvements & Request For Ideas #156

Open
CoreyKaylor opened this issue Jan 27, 2023 · 6 comments
Open

.NET 7 Improvements & Request For Ideas #156

CoreyKaylor opened this issue Jan 27, 2023 · 6 comments

Comments

@CoreyKaylor
Copy link
Owner

I'm catching up on some of the improvements made over the last few versions of .NET. I noticed that 7 has a new LibraryImport attribute that I could possibly leverage. What other things should I consider for this library? Open to hearing all ideas, but I'm keenly interested in the lower level items that this library will benefit from as-is.

Regardless of how much is taken on. I'm likely to release one more version for netstandard that has the latest 0.9.29 binaries included for all supported runtimes. After that I'm likely to drop support for netstandard and focus only on newer runtimes going forward. How do others feel about this?

@CoreyKaylor
Copy link
Owner Author

I've opened #158 with my initial pass at these improvements.

@AlgorithmsAreCool
Copy link
Collaborator

There are probably some hygiene features we can use such as more nullable annotations and use of the scoped keyword on stackallocated buffers.

@CoreyKaylor
Copy link
Owner Author

What would scoped keyword buy us in this case? I'm not too familiar with the latest changes there.

@AlgorithmsAreCool
Copy link
Collaborator

Probably not a ton? It has to do with escape semantics of ref-like types such as Span since they can use stackallocated memory that is invalid if passed back to parent frames. I'd need to eyeball the code to see if we bother with that anywhere. But it is a new language safety feature.

Now that i'm thinking about it, it might be worth running some performance experiments with new runtime features. In the past I've seen other high-performance libraries use the IL calli instruction to perform low overhead calls, but it wasn't really safe at the time. These days, function pointers can use that instruction in a safe manner and there is also the new-ish CallConvSuppressGCTransition and SuppressGCTransition attribute that might reduce overhead also. But those need careful consideration due to some bad issues they can cause.

@CoreyKaylor
Copy link
Owner Author

Interesting, although looking briefly at the docs and it seems they come with some pretty strict requirements.

@CoreyKaylor
Copy link
Owner Author

I like the nullable options now for reference types. I've been working on a Kotlin version of LMDB and it brings a very clean API to make it explicit. Once I've made some progress there, I'll circle back on this library to make similar changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants