Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gc_step_timeout()treatsget_high_resolution_time()as nanoseconds.On Windows, though, it returned raw
QueryPerformanceCounterticks (usually 10 MHz), so the limit was 100× too long.In xray-16,
lua_gc_timeout 1000gave eachCLevel::script_gc()call about 100 ms instead of 1 ms, which ran a full GC cycle every frame.Fix
(t / f) * 1e9 + (t % f) * 1e9 / f. The plaint * 1e9 / fwould overflowuint64_tafter ~30 minutes of uptime at 10 MHz. The split form gives the same result exactly and stays in range for any counter frequency below ~18 GHz.QueryPerformanceFrequencycosts ~1.6 ns, against ~17 ns forQueryPerformanceCounter.timeout_usec * 1000in 64 bits. It was a 32-bit multiply, which wrapped for timeouts over ~4.3 s.Only the Windows branch changes. Linux and macOS already returned nanoseconds, so Windows now behaves the same as they do.
Testing
Windows 11 x64, MSVC 2022:
lua_gc(L, LUA_GCTIMEOUT, 1000)on a ~300 MB heap: worst call 100.01 → 1.14 ms, average 71.56 → 1.01 mslua_gc_method gc_timeout, the main thread's wait on this task dropped from ~44 % to ~0.1 % of the frame, and the Lua heap stayed flat.