From 6bc7224d4c5fefed6488acef017f9ab7ff710342 Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Tue, 13 Oct 2026 18:14:16 +0800 Subject: [PATCH] L4 map use no sync fast route when enouge predict ahead --- LICENSE | 8 ++-- Nitload.nuspec | 2 +- logo/README.md | 11 ++++++ logo/nFramework-icon.svg | 11 ++++++ .../HighPerformance/Memory/L4.Map.cs | 15 ++++--- .../HighPerformance/Memory/L4.Predict.cs | 2 +- .../HighPerformance/Memory/L4.cs | 2 +- .../nif-head/NitloadFrameWork.h | 39 ------------------- 8 files changed, 39 insertions(+), 51 deletions(-) create mode 100644 logo/README.md create mode 100644 logo/nFramework-icon.svg delete mode 100644 src/Nitload.Native/nif-head/NitloadFrameWork.h diff --git a/LICENSE b/LICENSE index 6ca16d5a..671b4918 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Nitload StgSharp Team +Copyright (c) 2024 Nitload Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,9 +20,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -StgSharp program uses the following open source projects, -I'd like to refer to them here and show my sincere appreciation, -while the names are sorted in no particular order +The nFramework project uses the following open-source projects. +Their respective license notices are reproduced below, +and the projects are listed in no particular order. 1. GLFW diff --git a/Nitload.nuspec b/Nitload.nuspec index e1223a00..d8d89937 100644 --- a/Nitload.nuspec +++ b/Nitload.nuspec @@ -11,7 +11,7 @@ https://github.com/Nitload-NSI/StgSharp No des right now Summary of changes made in this release of the package. - Nitload reserve + Copyright (c) 2024 Nitload OpenGL C# diff --git a/logo/README.md b/logo/README.md new file mode 100644 index 00000000..6b1b38ec --- /dev/null +++ b/logo/README.md @@ -0,0 +1,11 @@ +# nFramework Icon + +`nFramework-icon.svg` is the icon-only version of the nFramework mark. + +Copyright (c) 2026 Nitload. + +The artwork in this directory is licensed under the [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0)](https://creativecommons.org/licenses/by-nc-nd/4.0/). + +You may copy and redistribute the unmodified artwork for noncommercial purposes when you give appropriate credit and link to the license. This license does not permit distributing adaptations, and it does not grant permission for commercial use. Contact the copyright holder for other permissions. + +The repository's root MIT License applies to software, not the artwork in this directory. This copyright license does not grant trademark rights in the Nitload or nFramework names or marks, including the former StgSharp name, or imply endorsement. \ No newline at end of file diff --git a/logo/nFramework-icon.svg b/logo/nFramework-icon.svg new file mode 100644 index 00000000..d0cd4f77 --- /dev/null +++ b/logo/nFramework-icon.svg @@ -0,0 +1,11 @@ + + nFramework icon + The geometric nFramework mark, with a diagonal slash suggesting an N. + Copyright (c) 2026 Nitload. Licensed under CC BY-NC-ND 4.0: https://creativecommons.org/licenses/by-nc-nd/4.0/ + + + + + + + \ No newline at end of file diff --git a/src/Nitload.Common/HighPerformance/Memory/L4.Map.cs b/src/Nitload.Common/HighPerformance/Memory/L4.Map.cs index 0b718658..8e210473 100644 --- a/src/Nitload.Common/HighPerformance/Memory/L4.Map.cs +++ b/src/Nitload.Common/HighPerformance/Memory/L4.Map.cs @@ -35,11 +35,16 @@ namespace Nitload.Common.HighPerformance.Memory { try { - Predict(); - _ = Interlocked.Exchange(ref _swiss_swap_lock, 1); - while (Volatile.Read(ref _swiss_reader_counter) != 0) { } + int effectivePredictionCount = Predict(); + if (effectivePredictionCount > 0) + { + _ = Interlocked.Exchange(ref _swiss_swap_lock, 1); + while (Volatile.Read(ref _swiss_reader_counter) != 0) { } + + _addressMap.SwapBuffers(); + Volatile.Write(ref _predict_count, effectivePredictionCount); + } - _addressMap.SwapBuffers(); if (_addressMap.TryGet(source, out handle)) { throw new InvalidOperationException($"Unexpected map request: [address source: 0x{source.Address:x16}; layout profile: {source.Description:x16}]."); } @@ -52,7 +57,7 @@ namespace Nitload.Common.HighPerformance.Memory } else if (!TryGetAddress(source, out handle)) { throw new InvalidOperationException($"Unexpected map request: [address source: 0x{source.Address:x16}; layout profile: {source.Description:x16}]."); } - } else if (!TryGetAddress(source, out handle)) { + } else if (!_addressMap.TryGet(source, out handle)) { throw new InvalidOperationException($"Unexpected map request: [address source: 0x{source.Address:x16}; layout profile: {source.Description:x16}]."); } diff --git a/src/Nitload.Common/HighPerformance/Memory/L4.Predict.cs b/src/Nitload.Common/HighPerformance/Memory/L4.Predict.cs index 333fe530..01ef1212 100644 --- a/src/Nitload.Common/HighPerformance/Memory/L4.Predict.cs +++ b/src/Nitload.Common/HighPerformance/Memory/L4.Predict.cs @@ -16,7 +16,7 @@ namespace Nitload.Common.HighPerformance.Memory public unsafe partial class L4 { - internal partial void Predict() { } + internal partial int Predict() => 0; } } diff --git a/src/Nitload.Common/HighPerformance/Memory/L4.cs b/src/Nitload.Common/HighPerformance/Memory/L4.cs index 54ec138d..8fa59c19 100644 --- a/src/Nitload.Common/HighPerformance/Memory/L4.cs +++ b/src/Nitload.Common/HighPerformance/Memory/L4.cs @@ -81,7 +81,7 @@ namespace Nitload.Common.HighPerformance.Memory return _bufferAllocator.TryAlloc(size, out handle); } - internal partial void Predict(); + internal partial int Predict(); } } diff --git a/src/Nitload.Native/nif-head/NitloadFrameWork.h b/src/Nitload.Native/nif-head/NitloadFrameWork.h deleted file mode 100644 index df1f430f..00000000 --- a/src/Nitload.Native/nif-head/NitloadFrameWork.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef NIF_NATIVE_H -#define NIF_NATIVE_H - -#ifdef __cplusplus -#error "This header is not meant to be included in C++ code. Nitload.Native is a C library and should be used with C linkage." -#endif - -#include "nif_internal.h" -#include "nif_target.h" - -#include -#include -#include - -#define byte char -#define cs_char uint16_t -#define nif_null_assert(ptr) assert(ptr != NULL) - -#ifndef NIF_ -#endif - -NIF_API void NIF_DECL nif_load_glfw_functions(GLFWFunctionTable *table); -NIF_API void NIF_DECL nif_load_intrinsic_function(void *intrinsic_context, uint64_t id); -NIF_API SIMDID NIF_DECL nif_get_simd_level_global(); -/* Per-core variant: always re-executes CPUID, never caches. - * Must be called on the target core (after affinity is set). */ -NIF_API SIMDID NIF_DECL nif_get_simd_level_local(); -NIF_API SIMDID NIF_DECL nif_get_unite_simd(SIMDID left, SIMDID right); -NIF_API int NIF_DECL nif_compare_simd(SIMDID left, SIMDID right); -NIF_API void NIF_DECL nif_set_thread_affinity(int cpu_index, int processor_group_id); -NIF_API void* NIF_DECL nif_numa_alloc(size_t size, int numa_id); -NIF_API void NIF_DECL nif_numa_free(void *ptr, size_t size, int numa_id); -NIF_API int NIF_DECL nif_get_numa_each(int numa_id, - uint32_t *processor_group_ids, - uint32_t *socket_ids, - uint32_t *cpu_indices, - uint32_t *numa_node_ids); -NIF_API int NIF_DECL nif_get_numa_overall(int *out_numa_count, int *count_of_each_numa); -#endif