WIP: perf(hle): GetCurrentThread, GetTlsValue, SetTlsValue and a thread's own GetThreadPriority answered at their call sites in lifted code (A64_OS_INLINE) #1956
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1956
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/os-inline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
nn::os::GetCurrentThread,GetTlsValue,SetTlsValueandGetThreadPriorityare HLE functions(
host/hos_thread.c) that each read or write one field of the calling thread's record. Called from lifted code, eachpays the whole way out for it: the caller's guest registers written to the context and read back after the call, the
hooked definition's tail call,
HOS_HLE_STATS's test and the host thread-localcur.GetTlsValuehas the most callsites of any HLE function in the game.
This PR answers them where lifted code calls them (lift time,
A64_OS_INLINE, on by default):nx2/guest_os.pyrewrites each direct call, the likely arm of a devirtualised call, and each tail call of their hookeddefinitions into the field access itself, through the context's thread pointer (
Ctx.thread, theHosThreadrunning the context; a fiber's context takes its thread's at each switch).
GetThreadPriorityis answered so only forthe calling thread's own
ThreadType(the HLE function's own fast case,thread_arg); about another thread it callsthe hooked definition as before, as a
TAILCALLwhere the call was a tail call. Calls through a pointer and theemitted bodies of PLT stubs (a function pointer can enter one) still reach the HLE functions; a function that calls
none of the hooked definitions (its refs) is not scanned.
HosThreadHead(guest_tt,tls_slots[32],priority), declared in the generateda64.h(nx2/rtgen.py), which the host includes too.HosThreadstarts with those fields;host/hos_thread.casserts their offsets and sizes against
HosThreadHead, and the lifted code reaches them asHosThreadHead(
tls_slotsindexed as its array).vc_sync_tls) and the priority(
ChangeThreadPriority,svcSetThreadPriority) are written by other threads, so every access to them is atomic(relaxed): in the lifted code, the
GetTlsValue/SetTlsValueHLE functions,vc_pref_core,vc_sync_tls,hos_thread_priority(an exchange when it sets) and every scheduler and diagnostic read of the priority(
hos_thread_prio). Left as onmain(not this PR's fields):core_tls_slot, the slot index, is still avolatileread outside its lock in
vc_pref_core, andguest_ttis written byhos_thread_adopt_guestwithout atomics.nx2/lift.pyinstalls it at its module level and configures it in the standalone lift from the hooks;nx2/chunks.pysends its table to the emit's new processes.A64_OS_INLINE=0lifts as before; the switch is in thelift key. Its row is in
docs/dev/reference/build.md.On by default because it is bit-exact by test: the four HLE functions, cut from
hos_thread.c, against the inlined Cover two threads' records give the same registers and the same records, and the real emit's output (one process and
spawned ones) holds that C at each site and compiles.
HOS_HLE_STATS=1no longer counts the inlined calls: in a defaultlift its counts of the four are partial, which
scripts/perf.py cpu --callssays in its report anddocs/dev/reference/build.mdandprofiling.mdsay (lift withA64_OS_INLINE=0for full counts).From 4d98f819 (its lifter and
HosThreadhalf) and bb27910b onexp/x86-asm-sync.Read first:
nx2/guest_os.py;THREAD_HEADinnx2/rtgen.py; theHosThreadhead and its assert inhost/hos_thread.c;tests/test_guest_os.pyandtest_os_inlineintests/test_spawn_emit.py.Testing
Tested: Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5. These are game-free checks only,
plus a micro-benchmark run at an earlier form of the change. This change has not run in the game on this PC yet; the
run is queued (Still to test). Each check ran in a hidden console of its own, in one job of the PC's job queue
(fb-1956-2), on this branch rebased onto
main@f1f2dc5b(with #1949), head2a1ad8f2:python -I -B tests/test_guest_os.py(no--cc:LONGSHOT_MINGW's clang): exit 0, its lines: The same passed withCCset, in the run before the rebase (fb-1956-1, the same fix onmain@6e1521a7). At thetest commit (before the fix) it fails: "FAIL: GetThreadPriority reads its own thread's and calls the hooked
definition for another's" (fb-1956-1).
python -I -B tests/test_spawn_emit.py --cxx clang++(llvm-mingw's): both tests pass ("Ran 2 tests ... OK"),test_os_inlineamong them. At the test commit7df10ab4it fails as it should: "AssertionError: 9 != 8 : every callof a hooked definition outside a PLT stub is a site, and only those", because the PLT stub's body was rewritten.
python -I -B tests/test_invalidate_vcore.pyalone, twice at2a1ad8f2and once onmain@f1f2dc5b: all threepassed (every case,
immediateincluded). Before this round, HostLiftPRs had also run it twice alone atb922eadf,and both passed. Its two failures in the parallel
--changedruns were timeouts: atb922eadf, theimmediatecaseat 10 s; at this round's first head (fb-1956-1), its g++ compile.
python -I -B tests/run_all.py --strict --changed origin/mainat2a1ad8f2: exit 1, "81 passed, 15 failed, 3skipped". Skipped:
nx2/test_leaf.py, which needs the game's modules, andtests/test_posix_thread_priority.pyand
tests/test_tracy_funcs.py, which are Linux only. All 15 failures also fail onmain@6e1521a7with the samemessages; they were run there by name in fb-1956-1, and
main's one commit since then (f1f2dc5b, #1870) touchesnx2/oot_patches.pyand its own test. The 15:test_crash_record,test_dev_packs,test_host_guest_writes,test_libc_hooks,test_lift_cache,test_linux_preflight,test_make_game_ngx,test_mods_list,test_oot_shadow_fit,test_perf_report,test_profiling_mode,test_sdiv_overflow,test_slow_frames,test_vcore_escapeandtest_vcore_mask0. The last two fail compiling their own harness (hos_fps_timing,env_on_or) onmaintoo.Still to test:
main@f1f2dc5b(the mergebase), this PR with
A64_OS_INLINE=0(off) and this PR with it unset (on). Castle Town's market, a heavy scene anda fiber-heavy one, 60 s each, with the same save, settings and native resolution. Report average fps, 1% lows, and
median and p99 frame times. Each build is a lift of its own. Expecting the same game, no crash, and the on build at
least as fast as the other two (by hand, queued).
generated C and linked sizes. The first build of this PR compiles every lifted chunk again, because the generated
a64.hchanged (by hand).python3 -I -B tests/test_guest_os.pyandtests/test_spawn_emit.py,expecting the lift's line "nn::os field reads at their call sites" and the tests to pass (by hand).
minutes, this PR against
main(the PR's build lifts the game again), expecting the same game, no crash and frametimes as
main's or better (@Beanstalk play Castle Town's market for two minutes on PCs with AMD CPUs and on theSteam Deck, this PR against main, comparing frame times and checking for crashes)
Measurements
Verdict: micro-benchmark only, not measured in play yet: answered at its call site, GetTlsValue took 1.13 ns a call
against 2.56 ns through the HLE function, and a thread's own GetThreadPriority 1.14 ns against 2.96 ns (the second run:
2.56 -> 1.13 and 2.95 -> 1.13). No play measurement exists yet. These figures are of the inlined C as it was at
974297f5 (plain loads through
uint64_toffsets). The micro-benchmark has not been run again at2a1ad8f2, where the Creads through
HosThreadHeadwith relaxed atomics.Baseline: the before side is not a
mainbuild but the call as lifted code makes it today, built in the same test at974297f5 (
main@51f5f9dawith this change; the same lines as 73b63e17 after the rebase ontofc4a6769andb922eadfafter the one onto2e1f6c32): a call of thehooked definition, which calls the HLE function cut from
hos_thread.cbehindHOS_HLE_STATS's test, the context inmemory. The after side is the inlined C the lift emits instead.
Setup: Windows 11, i7-9700, llvm-mingw clang 23.1.5,
-std=gnu11 -O2(the test's own build).python -I -B tests/test_guest_os.py --cc clang --bench: a loop of 20,000,000 calls, best of 5, the test run twice in onetiming-cpujob of the PC's job queue.Risks
A lift change: a build of this PR lifts the game again (and again with
A64_OS_INLINE=0), and as the generateda64.hgains
HosThreadHeadits first build compiles every lifted chunk again, with the switch on or off. The inlined C readsthe record through
Ctx.thread; a context whose thread pointer were not the running thread's would read anotherthread's TLS. Every guest context gets it in
setup_guestand a fiber's at each switch, ascurdoes; the layout isasserted against
HosThreadHead.HOS_HLE_STATS=1counts fewer calls (partial for the four, said in the report).Turn it off with
A64_OS_INLINE=0at build time; a revert is enough. Players notice nothing (no saves, options orcaches change).
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Possibly related, for context:
Recommendation: Request changes. The new lifted accesses carry unsynchronized TLS and priority reads into code the compiler can optimize across call sites, and the TLS access indexes beyond the first C member. The Windows microbenchmark shows cheaper individual calls, but the default-on change still needs gameplay and build measurements.
The standalone lifter replaces four common OS calls with access to the running thread’s record. That can save host calls and register traffic, at the cost of coupling generated C to the host thread layout, adding work to the lift, and reducing the coverage of HLE call counts.
Does it help: Unproven in play. The author’s Windows 11 i7-9700 fixture at 974297f5 reported GetTlsValue at 2.56 → 1.13 ns in both runs and own GetThreadPriority at 2.96 → 1.14 ns and 2.95 → 1.13 ns. Each result is the best of five 20-million-call loops. There are no matched base-versus-HEAD gameplay runs, frame-time distributions, or clean-build time and size results.
Other systems: The change runs on the CPU across GPU vendors and drivers. Windows uses spawned emit workers, while Linux ordinarily forks. Both rely on the same thread layout and generated code, and neither has a reported production build and play run at HEAD. Virtual-core scheduling shares the TLS array and priority field. Fiber switches update Ctx.thread before resumption, making a migrated fiber an important test case. Profiling reports can undercount the four calls. The diff has no direct changes to rendering, audio, input, saves, or the renderer API.
Switches: A64_OS_INLINE is a new lift-time developer switch. Unset enables it and 0 disables it. The lift key includes it through the A64_ prefix, and the build reference documents it. The runtime switch table applies to switches the game reads. The default needs the correctness fixes and matched gameplay and build results. HOS_HLE_STATS remains off by default, and enabling it on a default lift yields partial counts for the four rewritten functions.
Reviewed:
b922eadf4aagainst2e1f6c32d3: Read nx2/guest_os.py, nx2/lift.py, nx2/chunks.py, tests/test_guest_os.py and docs/dev/reference/build.md in full. Read the full diff and commit, the changed host/hos_thread.c sections and the relevant setup, lifecycle, fiber, HLE and scheduler code. Traced hook resolution, register sync, worker initialization, the lift key, giant-function splitting, the test runner and profiling consumers. Read AGENTS.md, CONTRIBUTING.md, the PR template and developer standards. The local review checklist and sibling Tooling checkout were absent. Skimmed the recorded-run index and read the supplied testing, measurements and bot comment. No generated files or translations changed. Unrelated host code and historical runs were outside the detailed read.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Waiting on the author (a run, a measurement or a decision; no edit does it)
Suggestions (the author may take or leave)
Testing: Read-only review. The author reports 16,000 fixture comparisons passing on Windows at 73b63e17. The changed suite there reported 51 passed, 13 failed and 3 skipped, with 12 failures also on the corresponding baseline. No game run, Linux standalone build, or passing CI at
b922eadf4awas supplied.Overlaps and merge order: The supplied bot comment identifies #1952 as related with no direct file overlap and no merge-order dependency. #1209 is a merged precedent. The description mentions sibling mutex branches carrying the lift change, with no prerequisite shown.
Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.
@ -70,6 +70,7 @@ Read by the build, not the game, so they are not in `switches.def`.| `A64_FASTFP`, `A64_LOCAL_REGS`, `A64_LOCAL_FLAGS`, `A64_LOCAL_FUNCS` | Lift-time switches (`nx2/fastfp.py`, `nx2/guest_locals.py`); they change the lift key || `A64_FASTFP_STORES=0`, `A64_FASTFP_VMOVES=0` | Fast float regions (`nx2/fastfp.py`) stop at a guest store, or at a vector move or shuffle (`nx2/fastvec.py`'s `a64_vld16`, `a64_vdup`, `A64_EXT16`, `A64_EXT8`, `a64_tbl1`), as before. Both on by default: a region may hold stores but no load after one, and its fast copy keeps their addresses and values and stores them, in order, once its MXCSR check passed (its exact copy is unchanged). Lift-time switches: they change the lift key || `A64_VECFP=0` or a list of `elem`, `vec`, `minmax`, `fcvt` | The SSE fast paths for the float forms the translator otherwise does lane by lane (`nx2/vecfp.py`); each keeps a result only where it is provably Arm's, else the instruction's own C runs. All on by default; `0` lifts exactly as without them. A lift-time switch: it changes the lift key || `A64_OS_INLINE=0` | nn::os::GetCurrentThread, GetTlsValue, SetTlsValue and GetThreadPriority called as HLE functions, as before. On by default: each direct call (or tail call) of their hooked definitions is the field read or write itself, through the context's thread pointer (`nx2/guest_os.py`; the thread record's head is fixed and asserted in `host/hos_thread.c`); GetThreadPriority so only about the calling thread's own ThreadType, a call as before about another. The same x0, other registers and records as the HLE functions (`tests/test_guest_os.py`), no checkpoint skipped (they had none); calls through a pointer still reach the HLE functions, and `HOS_HLE_STATS=1` does not count the inlined ones. A lift-time switch: it changes the lift key |Mark partial counts in the profiling output and document the required off lift for full counts, or preserve full counts when HOS_HLE_STATS is enabled.
@ -0,0 +32,4 @@READS = {"_ZN2nn2os16GetCurrentThreadEv": "{ c->x[0] = ((const uint64_t *)c->thread)[0]; }","_ZN2nn2os11GetTlsValueENS0_7TlsSlotE":"{ const uint32_t _slot = (uint32_t)c->x[0]; c->x[0] = _slot < %du ? ((const uint64_t *)c->thread)[1 + _slot] : 0; }"The uint64_t pointer starts at guest_tt, so [1 + slot] crosses a scalar member even for slot 0. Address the real tls_slots array in both accessors.
@ -0,0 +35,4 @@"{ const uint32_t _slot = (uint32_t)c->x[0]; c->x[0] = _slot < %du ? ((const uint64_t *)c->thread)[1 + _slot] : 0; }"% SLOTS,"_ZN2nn2os11SetTlsValueENS0_7TlsSlotEm":"{ const uint32_t _slot = (uint32_t)c->x[0]; if (_slot < %du) ((uint64_t *)c->thread)[1 + _slot] = c->x[1]; }" % SLOTS,vc_sync_tls can write this slot from another thread during a same-core mask change. Use atomic accesses on the lifted, HLE and scheduler paths.
@ -0,0 +38,4 @@"{ const uint32_t _slot = (uint32_t)c->x[0]; if (_slot < %du) ((uint64_t *)c->thread)[1 + _slot] = c->x[1]; }" % SLOTS,"_ZN2nn2os17GetThreadPriorityEPKNS0_10ThreadTypeE":"{ const uint8_t *_th = (const uint8_t *)c->thread; if (c->x[0] == *(const uint64_t *)_th) ""c->x[0] = (uint32_t)*(const int32_t *)(_th + %d); else @F@(c); }" % PRIORITY_AT,Another thread can set this priority through nn::os or SVC. Use an atomic load here and in host readers, with an atomic exchange for the setter.
@ -0,0 +67,4 @@if body is None:return m.group(0)n += 1return body + (" return;" if tail else "")Keep the guaranteed TAILCALL on the other-thread fallback at tail sites. An ordinary call followed by return can retain the caller frame.
@ -0,0 +86,4 @@def emit_function(self, e, texts):text, refs = base(self, e, texts)table = getattr(self, "os_inline", None)if table:Emitted PLT bodies can be entered by an indirect call. Keep their HLE tail calls so function pointers through those stubs retain the documented behavior.
@ -0,0 +87,4 @@text, refs = base(self, e, texts)table = getattr(self, "os_inline", None)if table:text, n = inline(text, table)Use refs to skip scanning emitted functions with no eligible callees. The full lift emits roughly 1.5 GB of C.
@ -0,0 +29,4 @@import kit # noqa: E402,F401 (a64-kit's folders on the path)import guest_os # noqa: E402RUN_ALL_ARGS = ["--cc", "gcc"]Honor CC in the suite and standalone entry point so a supported Clang-only Linux setup can run this fixture.
@ -0,0 +87,4 @@"""nx2/lift.py installs the wrapper at its module level (the emit's new processes run it too) and configures it in thestandalone lift after the hooks are known; nx2/chunks.py sends the table to those processes"""import chunkscheck("os_inline" in chunks.EMIT_TABLES, "nx2/chunks.py's EMIT_TABLES sends os_inline to the emit's new processes")These checks pass if the wrapper discards its rewrite result. Compile real emitted C and compare single-process with actual spawned output using synthetic hooks.
Recommendation: Request changes. Use the actual TLS array and synchronize access to the slots and priority before enabling these shortcuts. Preserve tail calls and indirect entry behavior in the emitted code. Existing exact-head review
The TLS access indexes from
guest_tt, a scalar member. The virtual-core scheduler can also write a running thread’s core slot while its lifted code accesses it, and another guest thread can change its priority. A shared typed layout and consistent atomic access across the lifted code, HLE and scheduler paths would address both issues. On the emitter side, keep the other-thread priority fallback as a tail call and skip PLT bodies that can be entered through a function pointer. Extend the fixture to compile real emitted C in both single-process and spawned modes. Existing TLS finding Scheduler finding Priority finding Tail call finding Indirect entry finding Fixture findingDoes it help? Unproven in play. The author’s Windows i7-9700 fixture reports 2.56 → 1.13 ns per GetTlsValue call and 2.96 → 1.14 ns for a thread’s own GetThreadPriority, best of five.
A64_OS_INLINEdefaults on for standalone lifts and0restores the HLE calls. The lift key includes it. A default lift counts only the remaining HLE calls when profiling withHOS_HLE_STATS. Existing profiling findingTesting and merge order. Rebase through the renderer compile and Linux link fixes before collecting build or gameplay evidence. The Windows fixture passed before the last rebase. Rerun the Windows suite, including the
test_invalidate_vcore.pytimeout. That fixture uses its own thread layout and compiles helpers unchanged by this diff. Compare the rebased main and candidate in warmed, interleaved Market and heavy-scene runs. Include average FPS, 1% lows, median and p99 frame times, a build with the switch off, and clean lift/build time and size on Windows and Linux. Cover Tier 1 platforms, including Steam Deck. Head CI is pending and the farm has no jobs or reports. The register-pinning experiment also touches the lifter, so check generated code with both enabled if the changes are combined. Renderer compile fix Linux link fix Farm Register pinning PRReviewed
b922eadfagainst2e1f6c32. Read all six changed files at the diff, used revision-matched Graphify and checked the affected emitter, thread setup, fiber switch and scheduler source. The slot truncation and return convention match the HLE, and local register sync remains around direct and devirtualized calls. Nothing from the PR was run.b922eadf4a2a1ad8f217@Beanstalk This lifter change (A64_OS_INLINE, on by default, read at lift time) answers GetCurrentThread, GetTlsValue, SetTlsValue and a thread's own GetThreadPriority inline in the lifted code (nx2/guest_os.py, the HosThread head in host/hos_thread.c), so the PR's build lifts the game again and its lifted C differs from main's by design. It has not run in the game here with this head yet. Please time the lift against main's, then play Castle Town Market for two minutes, this PR against main, on a Windows PC with an AMD processor, a Linux PC with an AMD processor, a PC with 6 or fewer logical processors and the Steam Deck. No crash or hang, and the same game; frame time p99 equal to main's or better, within the run-to-run spread; lift time within main's spread or better.
@siantm only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@futondestroyer thanks for the review (62741). Fixed in
2a1ad8f2, with its tests in7df10ab4first. The branch is rebased ontomain@f1f2dc5b, which includes #1949.git range-diffshows the PR's own commit unchanged (aca07f9c=b922eadf).HosThreadHead(guest_tt,tls_slots[32],priority). It is declared once, in the generateda64.h(nx2/rtgen.pyTHREAD_HEAD), which lifted code and the host both include.host/hos_thread.casserts thatHosThread's fields have the same offsets and sizes asHosThreadHead. The inlined C now indexes((HosThreadHead *)c->thread)->tls_slots[_slot], so it no longer reaches pastguest_tt.GetTlsValue/SetTlsValueHLE functions,vc_pref_core's read andvc_sync_tls's write of the core cell, andhos_thread_priority, which now uses an exchange when it sets so it can return the old value. It also covers every scheduler and diagnostic read of the priority, which now go through an atomichos_thread_prio. I removed the unusedhos_tls_slots, which handed out the raw array. I kept this inside the PR: it is one file of host code plus the generated C. Two related things stay as they are onmain, because they are not fields this PR inlines. The slot indexcore_tls_slotis still avolatileread outsidetls_slot_lockinvc_pref_core.hos_thread_adopt_gueststill writesguest_ttplainly. The description says so.GetThreadPriorityabout another thread is aTAILCALLof the hooked definition again, not a call followed by a return.nx2/split_giants.pykeeps it a tail call: the piece returns the tail id and the dispatcher's case isTAILCALL(f_…).tests/test_guest_os.pychecks this through a cut giant, and its C fixture runs the tail form against the HLE function.tests/test_spawn_emit.pyhas a new configuration,test_os_inline. Its made-up image hooks four functions, which are reached by BLs, a devirtualised arm, a B and a PLT stub. It runs the real emitter withA64_LOCAL_REGS=4in 1 process and in 3 spawned ones (the wrapper is installed at the file's module level, asnx2/lift.pydoes) and gets the same files both ways. Each site holds the expected C, the stub stays whole, and the files holding sites compile against the generateda64.h. It also runs withA64_OS_INLINE=0, with no site.Test results, from this PC's job queue (Windows 11, llvm-mingw clang 23.1.5):
2a1ad8f2, in job fb-1956-2:tests/test_guest_os.pypasses.tests/test_spawn_emit.pypasses. At the test commit7df10ab4it fails: the PLT stub's body was rewritten, so 9 sites against 8.tests/test_invalidate_vcore.pypasses, run alone twice and once onmain@f1f2dc5b.run_all.py --strict --changed origin/maingives 81 passed and 15 failed. All 15 also fail onmainwith the same messages,test_vcore_escape/test_vcore_mask0included (their harnesses do not compile onmain).test_guest_os.pyalso passed withCCset, and failed at the test commit.Still open on my side: the in-game runs (warmed and interleaved Market and a heavy scene, against the rebased
main, with a switch-off build and a fiber-heavy scene), clean lift and build time and size on Windows and Linux, Linux, Tier 1 (including the Steam Deck), and CI at this head.Point by point for BeanBot's review (62005) at
2a1ad8f2. The tests are in7df10ab4and the fix is2a1ad8f2. The branch is rebased ontomain@f1f2dc5b, and the PR's own commit is unchanged. These are the same changes as in my reply to futondestroyer's review.tls_slotsthroughguest_tt: fixed. The record's head is now the shared typeHosThreadHead, declared in the generateda64.h(nx2/rtgen.py) and included by the host too. The lifted code indexes itstls_slotsarray, andhos_thread.casserts the offsets against it.vc_sync_tls: fixed. TLS slot accesses are atomic (relaxed) in the lifted code, the HLEGetTlsValue/SetTlsValue,vc_pref_coreandvc_sync_tls. The slot indexcore_tls_slotstays avolatileread as onmain; the description says so.hos_thread_prioand in every scheduler and diagnostic reader inhos_thread.c. The setterhos_thread_priorityuses an atomic exchange that returns the old value.TAILCALLin the other-thread arm: fixed.tests/test_guest_os.pychecks it directly and throughnx2/split_giants.py's pieces.tests/test_spawn_emit.pychecks it in the real emit.e in self.plt.test_os_inlinechecks that the stub still tail-calls the hooked definition.test_os_inlinecounts the scans: there is one per function with a hooked call, against all 4,500 functions before.HOS_HLE_STATScounts: marked and documented, not preserved. Counting at each inlined site would add the check the change removes.scripts/perf.py cpu --callsnow says in its report that the four functions' counts are partial withA64_OS_INLINEon.docs/dev/reference/build.mdandprofiling.mdsay to profile a lift withA64_OS_INLINE=0for full counts.tests/test_spawn_emit.pytest_os_inline. It coversA64_LOCAL_REGS=4, BLs, the devirtualised arm, a tail call, a PLT stub and the unchanged indirectA64_ICALL. Output is the same in 1 and 3 spawned processes, with the switch on and with=0, and the files with sites compile against the generateda64.h. At the test commit7df10ab4, before the fix, it fails.CC: fixed. The order is--cc, thenCC, thenLONGSHOT_MINGW's clang (Windows), then clang, gcc or cc.RUN_ALL_ARGSno longer forces gcc. This is the same helper as #1954's.Waiting items: the
test_invalidate_vcore.pytimeout. Answered: it passed alone twice atb922eadf(HostLiftPRs' batch 8), and twice alone at2a1ad8f2plus once onmain@f1f2dc5b(fb-1956-2). Its failures happened only in the parallel changed-file runs, and both were timeouts: theimmediatecase at 10 s, and once its g++ compile. The in-game A/B (merge base vs head, switch off vs on, a fiber-heavy scene, Tier 1 incl. Steam Deck) and the clean lift/build time and size on Windows and Linux are pending on my side; they need runs I have not made. The suggestion about the micro-benchmark's clock is not taken this round. Its figures in Measurements are from 974297f5's form of the inlined C and were not run again at this head.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.