Page 3 of 3

Re: Replace QPC to RDTSC Timer in games

Posted: 09 Jan 2022, 09:47
by pox02
my final fix for rdtsc

To prevent this the programmer must serialize the the instruction queue. This can be done by inserting a serializing instruction like CPUID instruction before the RDTSC instruction

Code: Select all

.code
  GetCycleCount proc
    cpuid
    rdtsc
    ret
  GetCycleCount endp
end

Re: Replace QPC to RDTSC Timer in games

Posted: 10 Jan 2022, 12:01
by Ilim
how to use it, tell me, otherwise I don't understand programming

Re: Replace QPC to RDTSC Timer in games

Posted: 11 Jan 2022, 10:04
by pox02
i would like to avoid SetProcessAffinityMask/ SetThreadAffinityMask and change freq more for much more stable rdtsc i suggest use processhacker taskmgr process lasso and disable core 0 there much better

Code: Select all

LONGLONG GetFrequency(DWORD sleepTime)
{
    LARGE_INTEGER fq, st, ed;
    QueryPerformanceFrequency(&fq);
    QueryPerformanceCounter(&st);
    LONGLONG begin = GetCycleCount();
    Sleep(sleepTime);
    QueryPerformanceCounter(&ed);
    LONGLONG usec = (ed.QuadPart % st.QuadPart) * 1000000 / fq.QuadPart;
    LONGLONG end = GetCycleCount();
    return (end - usec - begin) * fq.QuadPart / (ed.QuadPart - st.QuadPart);
}

Re: Replace QPC to RDTSC Timer in games

Posted: 13 Jan 2022, 16:52
by pox02
My Final update of RDTSC is using RDTSCP which more efficiently now we back to use SetThreadAffinityMask in core 0 since without its can cause drift time and loops in cores reduce the freq to 1 microsecond more efficiently Enjoy the best timer :D

RDTSC + CPUID (in reverse order, here) to flush the pipeline, and incurred up to a 60x overhead (!) on a Virtual Machine (my working environment) due to hypercalls and whatnot. This is both with and without HW Virtualization enabled.

Most recently I've come across the RDTSCP* instruction, which seems to do what RDTSC+CPUID did, but more efficiently as it's a newer instruction - only a 1.5x-2x overhead, relatively.


i update here so u guys can compile it https://github.com/Zcytxcbyz/DLLHighResolutionTimer

Re: Replace QPC to RDTSC Timer in games

Posted: 13 Jan 2022, 17:06
by Plznoinputlag
pox02 wrote: ↑
13 Jan 2022, 16:52
My Final update of RDTSC is using RDTSCP which more efficiently now we back to use SetThreadAffinityMask in core 0 since without its can cause drift time and loops in cores reduce the freq to 1 microsecond more efficiently Enjoy the best timer :D

RDTSC + CPUID (in reverse order, here) to flush the pipeline, and incurred up to a 60x overhead (!) on a Virtual Machine (my working environment) due to hypercalls and whatnot. This is both with and without HW Virtualization enabled.

Most recently I've come across the RDTSCP* instruction, which seems to do what RDTSC+CPUID did, but more efficiently as it's a newer instruction - only a 1.5x-2x overhead, relatively.


i update here so u guys can compile it https://github.com/Zcytxcbyz/DLLHighResolutionTimer
but u cant use this in online games useles thing

Re: Replace QPC to RDTSC Timer in games

Posted: 27 Aug 2022, 19:28
by uzbek
pox02 wrote: ↑
26 Dec 2021, 11:47
i would like to update code so u guys get more game feeling by using the function QueryThreadCycleTime enjoy :D

Code: Select all

LONGLONG GetFrequency(DWORD sleepTime)
{
    LARGE_INTEGER fq, st, ed;
    QueryPerformanceFrequency(&fq);
    QueryPerformanceCounter(&st);
    QueryThreadCycleTime(GetCurrentThread(), &st);
    LONGLONG begin = GetCycleCount();
    Sleep(sleepTime);
    QueryPerformanceCounter(&ed);
    QueryThreadCycleTime(GetCurrentThread(), &ed);
    LONGLONG end = GetCycleCount();
    return (end - begin) * fq.QuadPart / (ed.QuadPart - st.QuadPart);
}

hi how i can use it?

Re: Replace QPC to RDTSC Timer in games

Posted: 28 Aug 2022, 23:30
by Cyanide_
Plznoinputlag wrote: ↑
13 Jan 2022, 17:06
but u cant use this in online games useles thing
And he posted it on Overclock electricity issue forum, like some DLL would help vs electricity caused "input lag/delay" lmao