-
Notifications
You must be signed in to change notification settings - Fork 49
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
PC-BASIC 2 graphics do not update between PSET calls #166
Comments
This also occurs in text mode.
Simple program that adds 0.1 repeatedly and draws the results. p.s. Unrelated to the bug: This reminiscent of a very old program I made as a kid where I was amazed that adding 0.1 over and over again would not result in accurate results, and furthermore, you could watch the velocity of the accumulative error, and the acceleration changes as it would jump into positive flow, then negative flow. |
…nderstood workaround of double sleep(0) call
Thanks for reporting, fixed with issue 8d1ae6f. The fix is to call |
The issue is still present when using more than one core due to, I think, python's GIL. i76700 - 1 CPU, 4 CORES, 8 THREADS |
I'm sorry @theruler can you please explain what you're doing? What is "affinity"? I do not see this problem anymore on my machine (which is also multi-core) so would need more information to be able to reproduce. |
Yes, sure.
I get the same results of jdoucette, the output is slow and stalls updating randomly. To solve the issue OS side, you have to open Task Manager, "details" tab, find pcbasicw.exe process, click the right mouse button on it and select "process affinity". Hope this was of help to you. Regards |
I did some timing tests with and without A$=INKEY$ and using single or multi cpu affinity.
multi: 18 sec (choppy output)
multi: 87 sec (smooth output) |
Thanks @theruler for the metrics. So this is actually a slightly different issue as the original issue occurred on single-core as well, and led to a complete block of screen updates. That has been resolved, however what we're seeing here is choppy updates on multi-core machines, at least under Windows. You are probably right that this is related to the GIL. It looks similar to this: https://www.rfk.id.au/blog/entry/a-gil-adventure-threading2/ . The analysis in that case is that when the threads execute on different cores, they race to acquire the GIL and this leads to slower performance on multiple cores than on single core. In-depth explanation in David Beazley's slides here http://www.dabeaz.com/python/UnderstandingGIL.pdf However:
The root cause of the issue I think is that (given the GIL in CPython) the display thread simply has too much CPU work to do to keep up with the engine thread, which unfortunately takes rather big changes to address and is something I'd defer until we have better test coverage. It may be possible to work around the issue by explicitly setting the affinity from the code - however for some reason |
Further update
For reference, on Linux, these are "smooth":
while this is "choppy":
Here, |
correct. I am not concerned about speed per se, what I think pc-basic should achieve is the same speed as an old 386, on all system independently. |
Further tests OS side (windows 10). windist - PC-basic 2.0.6 - Python 3: pure python PC-basic 2.0.6 - Python 3: PC-basic 1.2.15 - Python 2: The kernel is that part of the operating system that acts on behalf of all the applications and services running on the system. The kernel is the only part that of the operating system that has access to the physical resources of the computer. Access to the kernel is handled through very specific, highly privileged, API calls. The most common culprit of run-away kernel time is a poorly written device driver. Another could be a failing hardware device that is causing a flood of hardware interrupts - hardware interrupts are handled only by the kernel. In a system that is not really running any applications, the kernel continues to perform its functions, which includes all sorts of 'house-keeping' tasks to ensure the system is running correctly. Therefore, if no user processes are running, kernel time will be a higher percentage of overall usage. But as the number of user processes kick in, you will see the percentage of kernel versus user time go down. Lastly, if you have to ask what kernel time is, you are most likely not the person to 'debug' it. There are very few people who work in kernel development and troubleshooting. |
By the looks of that log, PC-BASIC would have ran in text mode without using SDL2. You'd notice though, it looks rather different, running in the command prompt window rather than opening a window of its own. |
@robhagemans do you have any eta of a new version that would include this fix? |
Hi, I'm afraid I can't give an ETA, this is purely a project I work on in
spare time.
I've been meaning to spend a bit of time on it for a while but have been
busy with other projects and of course the day job
…On Mon, 13 Mar 2023, 14:57 Stefano Crespi, ***@***.***> wrote:
@robhagemans <https://github.com/robhagemans> do you have any eta of a
new version that would include this fix?
—
Reply to this email directly, view it on GitHub
<#166 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB25RESINSAATY2OUBHOOOTW34YVDANCNFSM5H7IUQWA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Bug report
See: https://www.youtube.com/watch?v=9J9DtrcoDXc
Problem
Steps
Program
Notes
PC-BASIC version: 2.0.4
Operating system version: Windows 10
The text was updated successfully, but these errors were encountered: