Lazarus

Free Pascal => Windows => Topic started by: deanon on January 09, 2018, 09:26:15 pm

Title: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 09:26:15 pm
Hi guys, after installing windows patch related to subj, compiler performance has degradated dramatically, about 8 times for my project. Before its build was taking about 5 sec, now it is about 40 sec (!). Not to mention, I have all files and build process set up on RAMdrive. Could you please tell me there are some good news about this ahead? I've chosen fpc for this project especially because of its speed, now this advangage seems to be lost...
Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 09:32:44 pm
Was already wondering when somebody would take this as an excuse to try bash fpc.  :)

These cpu fixes apply to the whole performance of your machine. It shows up in your face in a a more obvious way when compiling. But, any compiler would suffer from this and as such is not fpc/lazarus related.

If that is reason for you to not choose fpc for your projects then i wish you a good of luck with using any other compiler/language. You'll notice that performance penalties are worse there as it accumulates. Worse before means more worse after patching.
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 09:37:57 pm
That is not excuse.
Compiler actually has nothing to do with system api calls (which is the cause of slowdown), the only reason for it is affected by patch, is that compiler do use api calls where they are not necessary. Compiler's work is to build an executable. I believe fpc slows down that much because its operation is based on files w/o abstraction.
Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 09:41:36 pm
Please read up on spectre and meltdown issues. The cause has nothing to do with system api calls. Where do you get your information from ?
Title: Re: Meltdown and Spectre related performance degradation
Post by: lainz on January 09, 2018, 09:44:12 pm
Meltdown and Spectre has only issues with FPC everyone knows that molly! If you use C it works fine =)

Go and use C.  ;D
Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 09:46:35 pm
@lainz:
You use compelling arguments... i think you convinced me. I'll start using c now ;D

Any hint on where to find me a c compiler that does not use system api calls ?  >:D
Title: Re: Meltdown and Spectre related performance degradation
Post by: Thaddy on January 09, 2018, 09:49:00 pm
Meltdown and Spectre has only issues with FPC everyone knows that molly! If you use C it works fine =)

Go and use C.  ;D
WHAT! FPC doesn't even optimize for pipe lined code!  Do not ever never give an ill informed answer.  A wrong answer is OK, but never ever without knowing what you are talking about. <2018  >:( >:(>
Sheer stupitity when you follow this: https://twitter.com/brainsmoke/status/948561799875502080
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 09:49:45 pm
Well then tell me please what it has to do with.
It is directly bound to system api call, because most of file operations are executing on kernel level (syscall).
Title: Re: Meltdown and Spectre related performance degradation
Post by: lainz on January 09, 2018, 09:50:51 pm
Meltdown and Spectre has only issues with FPC everyone knows that molly! If you use C it works fine =)

Go and use C.  ;D
WHAT! FPC doesn't even optimize for pipe lined code!  Do not ever never give an ill informed answer.  A wrong answer is OK, but never ever without knowing what you are talking about. <2018  >:( >:(>

Thaddy did you see the icon I posted, it was a joke, if anyone thinks that obviously is not well informed at all!
Title: Re: Meltdown and Spectre related performance degradation
Post by: lainz on January 09, 2018, 09:54:36 pm
@lainz:
You use compelling arguments... i think you convinced me. I'll start using c now ;D

Any hint on where to find me a c compiler that does not use system api calls ?  >:D

=)

I remember because I stopped making jokes.  ::) But at least with the first part of the response you are the only one that maybe got it was a joke?
Title: Re: Meltdown and Spectre related performance degradation
Post by: Thaddy on January 09, 2018, 09:56:24 pm
@lainz:
You use compelling arguments... i think you convinced me. I'll start using c now ;D

Any hint on where to find me a c compiler that does not use system api calls ?  >:D

=)

I remember because I stopped making jokes.  ::) But at least with the first part of the response you are the only one that maybe got it was a joke?
https://twitter.com/brainsmoke/status/948561799875502080 .....  >:D :D :D

It is not a joke.... It works...
Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 10:07:10 pm
Well then tell me please what it has to do with.
It is directly bound to system api call, because most of file operations are executing on kernel level (syscall).
Spectre (https://en.wikipedia.org/wiki/Spectre_(security_vulnerability))... meltdown (https://en.wikipedia.org/wiki/Meltdown_(security_vulnerability))

Where does it read that those are system api call related ?

They are cpu related issues. If the OS patches it in such a way that OS performance get affected then it affects the whole performance of that OS, and not for FPC alone. The implication that you try to make there simply does not make any sense (even if you would have been correct)

@lainz:
Yups, got you there right from the start  :)
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 10:10:22 pm
Well then tell me please what it has to do with.
It is directly bound to system api call, because most of file operations are executing on kernel level (syscall).
Spectre (https://en.wikipedia.org/wiki/Spectre_(security_vulnerability))... meltdown (https://en.wikipedia.org/wiki/Meltdown_(security_vulnerability))

Where does it read that those are system api call related ?

They are cpu related issues. If the OS patches it in such a way that OS performance get affected then it affects the whole performance of that OS, and not for FPC alone. The implication that you try to make there simply does not make any sense (even if you would have been correct)

molly, do you contribute to fpc development? If not, please do not post in this topic, if yes, please leave the team.
Title: Re: Meltdown and Spectre related performance degradation
Post by: lainz on January 09, 2018, 10:16:10 pm
@lainz:
Yups, got you there right from the start  :)

Thanks.

Of course I protected my PC's and the browser.

BTW I did not notice too much slow down.

molly, do you contribute to fpc development? If not, please do not post in this topic, if yes, please leave the team.

And you? People is trying to explain you that if it slow down something, is for everything not just FPC.
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 10:24:18 pm
lainz, people do not try to explain, they try to excuse for flaw that was suddenly discovered due to environmental conditions, and convince that it is okay. I just would like to know if someone is going to take care about it, because degradation is incomparable to average shown by benchmarks on the net. 30% is not 800%
Title: Re: Meltdown and Spectre related performance degradation
Post by: marcov on January 09, 2018, 10:24:29 pm
Please read up on spectre and meltdown issues. The cause has nothing to do with system api calls. Where do you get your information from ?

Meltdown does.  The common solution is to separate userland and kernel memory spaces, making switching between them more expensive. But the current Linux patches are provisional, some of the overhead will be fixed  by later patches using PCID on (afaik available on most 64-bit capable CPUs). The Windows patches for meltdown should already use PCID, so any slowdown over 10% is highly unlikely.

(which makes his observations really suspect, since he is using windows. Moreover, not every call from application to system leads to a syscall, there is user32.dll inbetween)

Spectre is easier, don't link scripting languages into your binary. Then nobody can execute code in your binaries, and done.

Anyway, in conclusion: measure better. The most rational conclusion is that the reboot to apply the patches caused his antivirus to go haywire.

Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 10:26:28 pm
Well then tell me please what it has to do with.
It is directly bound to system api call, because most of file operations are executing on kernel level (syscall).
Spectre (https://en.wikipedia.org/wiki/Spectre_(security_vulnerability))... meltdown (https://en.wikipedia.org/wiki/Meltdown_(security_vulnerability))

Where does it read that those are system api call related ?

They are cpu related issues. If the OS patches it in such a way that OS performance get affected then it affects the whole performance of that OS, and not for FPC alone. The implication that you try to make there simply does not make any sense (even if you would have been correct)

molly, do you contribute to fpc development? If not, please do not post in this topic, if yes, please leave the team.
FYI: yes, i have contributed (and still do) to FPC. No, I am not part of the FPC development team so you can relax about that.

I post wherever i wish to post unless one of the admins tells me to shut up.
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 10:32:01 pm
molly, ok reported
Title: Re: Meltdown and Spectre related performance degradation
Post by: molly on January 09, 2018, 10:39:37 pm
molly, ok reported
Purrfect !

Can't wait to hear the explanation that you couldn't share in public.
Title: Re: Meltdown and Spectre related performance degradation
Post by: marcov on January 09, 2018, 10:53:54 pm
Deanon: if you want to have an exclusive developer response file a bug, don't write in a public discussion forum.

But please provide extensive proofs and reproduction information for your problem or the response won't be much beyond an automatic "close -> Can't reproduce"

Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 09, 2018, 11:33:25 pm
Here are the measurements. I've just took my dusty old notebook (Pentium B960 2.4 ghz, 2Gb, not patched), and copied exact setup there. Build runs for less than 8 sec there (top of image).
My current desktop (i7 6700K, 4GHz, 16G, patched) builds this project for about 38 seconds (bottom of image).

(I've removed previous post because I've noticed desktop test was run with 3.0.0, but unfortunatelly, being fixed to 3.1.1 it didn't run better, so, posting again image with three screens)
Title: Re: Meltdown and Spectre related performance degradation
Post by: marcov on January 10, 2018, 06:50:45 am
The question is if the patches are the only difference. secruity software, windows version, or even just having run the command before (causing files to be cached)

Anyway, such a thing is probably not FPC related. My guess is that some system software reacts badly to the patches.

Are both cleanly installed windows versions? Anyway I guess that in the coming days more people will install the patches, and we'll see if that reacts the same.
Title: Re: Meltdown and Spectre related performance degradation
Post by: Pascal on January 10, 2018, 09:12:57 am
I did a quick test here:

"Cleanup and Build" of my project, 3 times:
Without patch: 38s / 37s / 36s
With patch: 37s / 36s / 36s

So pretty the same here: Windows 10 1709, SSD, i5-4440
Title: Re: Meltdown and Spectre related performance degradation
Post by: turrican on January 10, 2018, 12:27:59 pm
I didn't notice any drawback on my patched computers at all. Do you have antivirus enabled? Can be Windows drivers related? Another programs are running well? What Windows version are you using?
Title: Re: Meltdown and Spectre related performance degradation
Post by: Mick on January 10, 2018, 01:49:29 pm
From what I have read today, according to Microsoft, the performance penalties of their Meltdown patches depend on 2 factors:
- operating system version
- CPU micro-architecture

For Windows 10 the performance penalty will be least significant, for Windows 7 it will be most significant. Some say it is done on purpose by Microsoft to push people still using Windows 7 or 8/8.1 to move to Windows 10. Personally I doubt it is true, but maybe I am naive...

As for the CPU micro-architecture, the situation is very similar - for the newer the micro-architectures (Skylake, Kabylake) the performance penalty should be least noticeable, while on the older (Haswell and below) - the performance penalty will be noticeable. Some say that "money talks" also in this case, but again, personally I doubt it. I believe it is due to these small improvements in the micro-architecture over the generations (the source of these 5-10% IPC increases over each generation).

This is not good news for me, because I'm still running Windows 7 on SandyBridge...
Title: Re: Meltdown and Spectre related performance degradation
Post by: deanon on January 10, 2018, 09:48:16 pm
Good evening all, wrong alert - the main degradation source was Windows Defender. Have no idea why it started to cause so dramatic degradation, but with added exclusions now it builds for ~10 sec (for about 9 sec with entierely disabled defender), still worse than old Pentium B960, but it is quite acceptable.
Title: Re: Meltdown and Spectre related performance degradation
Post by: lainz on January 10, 2018, 10:04:26 pm
Good evening all, wrong alert - the main degradation source was Windows Defender. Have no idea why it started to cause so dramatic degradation, but with added exclusions now it builds for ~10 sec (for about 9 sec with entierely disabled defender), still worse than old Pentium B960, but it is quite acceptable.

You don't need to disable defender. Just add an exception to the path where lazarus and FPC lives, then problem solved.

The same happens with any antivirus software, these slow down or prevent compiling / running the newest binary.
Title: Re: Meltdown and Spectre related performance degradation
Post by: wp on January 10, 2018, 10:14:13 pm
Good evening all, wrong alert - the main degradation source was Windows Defender. Have no idea why it started to cause so dramatic degradation, but with added exclusions now it builds for ~10 sec (for about 9 sec with entierely disabled defender), still worse than old Pentium B960, but it is quite acceptable.
I noticed that Windows Defender became more aggressive after the 1709 update, similar to third-party antivirus. I had triggered this update manually and, therefore, I am very sure that the 1709 defender was the reason for the slow-down. Adding Lazarus and project folders to its exception list made it handsome again.
Title: Re: Meltdown and Spectre related performance degradation
Post by: marcov on January 10, 2018, 10:19:46 pm
I also updated, and ran some benchmarks before and after:

My W10 machine does is a I7-3770 12GB with SSD. Before patches (with hot SVN): 2min05 for snapshot build.  After patching 2min21

Note that another FPC developer in daenon's bugreport had no noticable slowdown with a i7-4770.

Ivy Bridge (3xxx) is on Intel's and Microsoft sh*tlist as the architecture to deprecate/replace this year (the generation that becomes 5 years old the coming year). No coincidence I guess.
Title: Re: Meltdown and Spectre related performance degradation
Post by: Thaddy on January 11, 2018, 12:21:03 pm
https://www.raspberrypi.org/blog/why-raspberry-pi-isnt-vulnerable-to-spectre-or-meltdown/
Title: Re: Meltdown and Spectre related performance degradation
Post by: PascalDragon on January 13, 2018, 02:02:43 pm
That is not excuse.
Compiler actually has nothing to do with system api calls (which is the cause of slowdown), the only reason for it is affected by patch, is that compiler do use api calls where they are not necessary. Compiler's work is to build an executable. I believe fpc slows down that much because its operation is based on files w/o abstraction.
I know you already found Windows Defender to be the reason, but nevertheless: of course a compiler has to do with System API calls. How do you think files are read and written? And in all monolithic OSes (Windows, Linux, Mac OS X to name the popular ones) file accesses always go through a System API and through the kernel.
Title: Re: Meltdown and Spectre related performance degradation
Post by: RAW on January 13, 2018, 04:28:52 pm
„The same procedure as every year/time“ ...  :D

I will never understand why people trust security software from MS or trust security software in general. In my eyes there are two good reasons for this kind of software: Money-Machine and Data-Collector. That doesn't mean software from a different vendor is automagically a better choice, but I don't see why MS should be so trustworthy....

And I will never understand why people think a patch or update after something went wrong should be called good security. Of course it's a nice name and it sounds very good ... (security update).


Quote
For Windows 10 the performance penalty will be least significant, for Windows 7 it will be most significant. Some say it is done on purpose by Microsoft to push people still using Windows 7 or 8/8.1 to move to Windows 10. Personally I doubt it is true, but maybe I am naive...
This is funny... would be very convenient for MS ... I think MS would dare to do things like that, but in this particular case I don't know...  :)
It's a known truth that MS did some other things to force people to use Windows 10.

I guess every intelligent being can find out the truth for itself.
Title: Re: Meltdown and Spectre related performance degradation
Post by: Thaddy on January 13, 2018, 04:40:32 pm
„The same procedure as every year/time“ ...  :D
Well, hardware hacks were missing for 30 years (yes, you could actually set a monitor on fire using software only on a 8086 with CGA card: this is not a hoax, we tried...it works...) , these are hardware issues that can be mitigated by software fixes at the expense of some performance. And by now are fixed in design.
Quote
It's a known truth that MS did some other things to force people to use Windows 10.

I guess every intelligent being can find out the truth for itself.
Like MS giving it away for free.... 8-) So true, so true... O:-)

Much like many here, and me, forcing you all to upgrade to FPC 3.0.4. and Lazarus 1.8.... Because I refuse to support anything that is not current.. Old stuff collects dust. Dust blurs your sight when it moves...
Title: Re: Meltdown and Spectre related performance degradation
Post by: RAW on January 13, 2018, 04:59:54 pm
Quote
Like MS giving it away for free.... 8-) So true, so true... O:-)
100% correct !
That's one very intelligent way to force people to use Windows 10.

Quote
...Because I refuse to support anything that is not current...
You can do whatever you like, but an old OS doesn't automagically mean that your system can be clobbered!
Title: Re: Meltdown and Spectre related performance degradation
Post by: Thaddy on January 13, 2018, 05:24:50 pm
I still support dialects of pascal on older software (TP mode, ISO mode). It is just that the distribution needs to be current. I am running some *very* old hardware at home... O:-) Like a real IBM PC... (Have to start it up: capacitors may be out by now...)
Title: Re: Meltdown and Spectre related performance degradation
Post by: PascalDragon on January 18, 2018, 10:04:29 am
I will never understand why people trust security software from MS or trust security software in general.

If I have to decide between security software from MS or some third party software I'd definitely use the MS one, because they know their OS and don't do strange hacks to get their software working. It's simply the choice between the lesser of two evils  :P