136

YouTube increases FreeBASIC performance (2019)

I was recently astonished when using speech recognition software on my computer finally made the computer silent. So when I use the speech recognition, my fan just stops. I investigated it and it does not stop, but the speech recognition software seems to slow down the fan to the minimal speed, even though the CPU cores are getting hotter and hotter. You never know these days what programs do.

3 hours ago0xcb0

Is it a Mac ? I think Macs always do that when they're actively listening with the internal microphone.

an hour agosimlevesque

I noticed in the thread that someone mentioned using `Sleep(16, 1)` gives a stable 60 fps, but I like to always drop a link to https://gafferongames.com/post/fix_your_timestep/ and decouple your game movement from your fps. It's a bit more math, but it is usually pretty smooth in my experience.

3 hours agomrozbarry

That link is not right either since it sets now to the current time instead of the time the frame will be displayed. This means that things will be rendered at the wrong positions than where they should be.

In regards to achieving smoothness you'll need to have proper frame pacing and the article doesn't mention how to do that properly.

24 minutes agocharcircuit

> Certain browsers allow YouTube to set the internal resolution of the timer to a lower value

It's wild to me that browsers expose this kind of control over my system to third party developers. I think making the browser an "application platform" was overall a mistake. Call me crazy, but I just want a browser that fetches and displays web sites.

36 minutes agoryandrake

Windows man. While linux is cursed in many ways, not being able to just know your PC's performance profile just seems so backwards to me. It's one of those things (lack of control) I don't miss.

3 hours agonoobermin

Linux also does timer coalescing? I'm not sure there's any real difference wrt. this behavior.

an hour agozozbot234

The same is true when running Winamp. When I was dabbling with FreeBASIC many years ago, my games performed better when I was listening to music. Same reason!

8 hours agoTonyTrapp

IS FreeBaisc still a thing nowadays ? I understand it's surely less popular, but are there people using it on HN ?

3 hours agowiz21c

Good question, I'm not even sure what I was looking up when I found that thread, I think I was curious about something else entirely, but as someone who learned to code with VB6 the link intrigued me, I mean come on, that thread title is just great.

I wanted FreeBASIC to have a RAD IDE back when I was still clinging to VB6 as it was being replaced by VB.NET. I hope someday Microsoft open sources bits and pieces of VB6.

2 hours agogiancarlostoro

We're up to GWBasic, so I'd hope for QuickBasic in its various forms, next.

After that are the various visual basics.

For DOS we are up to 4, hopefully 5 is next which has interesting TUI apps like DOSSHELL as well as QBasic and EDIT and QuickHelp.

2 hours agostuaxo

I imagine 99% of its use are people maintaining quickbasic legacy apps.

2 hours agozoeysmithe

>Windows Energy-saving timer heuristics

Another example of Windows' technical debt being there, low-hanging fruit-wise, to be cashed in by performance-oriented developers. Its interesting that Youtube changing the timer resolution propagates to other threads .. does this harken to darker days in the MSDOS era? Youtube, another Turbo button?

6 hours agoaa-jv

The best one, of course, is the one where Windows would install faster if you jiggled the mouse.

6 hours agofragmede

I was told a story by some hackers in the old multi-user mainframe days. They said that a good speed booster was to have the program open a terminal because it made the mainframe OS think it was a real-time user interactive program and give it more resources.

2 hours agofhdkweig

I this related to when you are scrolling and selecting within a document, and you wiggle the mouse, it scrolls faster ? I always thought it was just a nice UI optimisation, but I could believe it's actually some accidental side-effect at play.

(like make a 20 page word doc, and start selecting from the first page and drag through - it wil go faster if you jiggle. same in excel and nearly every windows app, even windows explorer)

6 hours agojaffa2

There must be so many subtle features like these that people use subconsciously, and when they try to move to another operating system, they try it, nothing happens and they get frustrated.

9 minutes agojoshuaissac

No, it has to do with every time you move the mouse over a window, a hover event is sent to the application, which runs its main event loop. Either the installer only updated its progress bar when an event happened (in which case it would only appear to be going faster, because the progress bar would move more smoothly) or there was some really terribly written code that literally only made progress when an (unrelated) event happened. My guess is the former.

5 hours agoninkendo

Being a bored kid in the 90s with nothing better to do, I had timed it. It was actually faster.

3 hours agomoron4hire

Makes me wonder how much of Windows is like Pokemon glitching, a community that never stops, even several generations ahead.

5 hours agogiancarlostoro

A performance issue related to this is more likely a shortcoming in the software experiencing this issue.

The setting in question is the minimum timer resolution. Changing this will only have an impact on applications that depend heavily on that resolution, i.e. it's not some sort of turbo button for general execution speed. In fact according to the docs, a higher resolution can "reduce overall system performance, because the thread scheduler switches tasks more often."

An application whose performance depends on the timer resolution should be setting that resolution itself, using the Win32 API function mentioned in the thread, timeBeginPeriod, which includes the following in its documentation:

> For processes which call this function, Windows uses the lowest value (that is, highest resolution) requested by any process. For processes which have not called this function, Windows does not guarantee a higher resolution than the default system resolution.

> Starting with Windows 11, if a window-owning process becomes fully occluded, minimized, or otherwise invisible or inaudible to the end user, Windows does not guarantee a higher resolution than the default system resolution. See SetProcessInformation for more information on this behavior.

> Setting a higher resolution can improve the accuracy of time-out intervals in wait functions. However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. High resolutions can also prevent the CPU power management system from entering power-saving modes.

https://learn.microsoft.com/en-us/windows/win32/api/timeapi/...

5 hours agoantonvs

Thats all well and good, but this part seems a bit .. uninformative, or at the very least, easily misunderstood by the harried developer:

>For processes which have not called this function, Windows does not guarantee a higher resolution than the default system resolution.

There should at least be mention that changing this resolution can effect other processes.

Is this a bug? Its hard to see it as a feature.

5 hours agoaa-jv

Think of it this way, the global timer resolution of the system is minOf(allProcessesTimerResolution). If no process needs higher accuracy timing then there is nothing hindering the system from sleeping longer periods to save power and/or have less interrupt overhead (An feature I'd say).

These API's are from the 90s, in the beginning of the 90s where these API's are from having an global system interrupt firing 1000 times per second could very well have taken a percent or two or more from overall CPU performance (people already complained about the "overhead" of having a "real OS").

On the other hand writing audio-players on DOS you had the luxury of receiving your own interrupt within a few samples worth of audio, this meant that you could have very tight audio-buffers with less latency and quicker response to user triggers.

Not having that possibility to get that timing fidelity would have made Windows a no-go platform for audio-software, thus giving developers the freedom to enable it when needed was needed. Removing it in the next 10 years would probably have risked bad regressions.

Like a sibling comment noted, they finally removed it during Windows 10's lifespan and with modern CPU's _AND_ multicore they probably felt safe enough with performance margins to separate high accuracy threads/processes to separate cores and let other cores sleep more and actually win more battery life out of it.

It might not be "perfect engineering", but considering the number of schedulers written for Linux over the years to address desktop(audio) vs server loads it was a fairly practical and usable design.

an hour agowhizzter

> There should at least be mention that changing this resolution can affect other processes.

That sorta is what it’s saying. If you don’t set it yourself, you won’t get any better than the “default system resolution”. But if the default system resolution changes (say, by entering a sort of “performance mode” when playing games or watching videos), then it would imply it will affect all processes that are using the default, right?

5 hours agoninkendo

Sorta, on Windows < 10. From the same Microsoft page:

“Prior to Windows 10, version 2004, this function affects a global Windows setting. For all processes Windows uses the lowest value (that is, highest resolution) requested by any process. Starting with Windows 10, version 2004, this function no longer affects global timer resolution.”

4 hours agoSomeone

Connections like this are fun and interesting but highlight what a complete junk pile our (extractive, spying, slow, bloated, eating power for no reason) stack is. we need a rewrite starting from the boot loader of almost every OS in use in the world

5 hours agouser3939382

The NT kernel is splendid. The OS is not.

4 minutes agorfl890

That would just create a bunch of new OSs that are worthless. Don’t forget the real point is to run applications, not an OS.

3 hours agoNetMageSCW

No the new OS can run the same applications with about 80% less electricity, apps are exactly the point that’s correct which is why the bloat monster stack is ridiculous it’s not needed