7 ms·
In a pointer heavy language like D, a 1% loss is a big deal. I.e. it would no longer be a systems programming language.
by WalterBright 4y ago
In a pointer heavy language like D, a 1% loss is a big deal. I.e. it would no longer be a systems programming language.
- hayley-patton 4y agoI would expect to be able to find another 1% slowdown somewhere in an implementation of another "system programming language" - would that also disqualify it from being such a language?
- WalterBright 4y agoIt's a competitive business. If a compiler generates 1% faster code, you need 1% fewer servers in your server farm, which translates to enormous amounts of money. Or if your hedgefund trading software runs 1% faster, you can get your trades in faster than the other guy, eating his lunch. Or would you like to reduce your costs of rented servers in the cloud by 1%?
- hayley-patton 4y agoRight, I don't mean to downplay the significance of 1%, but aren't there many ways to win or lose 1%? More specifically perhaps, are there so few GCed pointers that a faster collector cannot recuperate that 1%? moonchild's suggestion to monomorphise against GC/explicitly managed pointers might reduce that figure lower; evidently you know D programs better than I, but it doesn't seem unreasonable that the 1% can be won by a faster GC.
- WalterBright 4y ago> More specifically perhaps, are there so few GCed pointers that a faster collector cannot recuperate that 1%? Of course, it depends on your coding style, but yes, that is generally true.
- kohlerm 4y agoA 1% slowdown is a ridiculous low number IMHO. I would argue that almost no program is within 1% of the optimal speed (however you define it). Therefore practically it does not matter. If you think it matters then the consequence would be that you write everything in Assembler.
- WalterBright 4y ago> Therefore practically it does not matter. You won't notice it on your desktop. But you will notice it in cases I mentioned. Top shelf games also are not going to give up that 1%, or so the game devs tell me.
- pjmlp 4y agoAnd yet even the likes of Sony and Nintendo are working in major titles with Unity. Unity is also the official developer SDK for Microsoft's HoloLens Virtual Reality Toolkit.
- jcelerier 4y agoAnd 70 million people go eat Mickey D's every day, doesn't make it good in any way. Whenever I play unity games (rarely to be honest as I play maybe 5-20 hours a year nowadays, but this has been consistent) I brace myself for a laggy experience. Most people don't care about this it seems but it really makes me want to close the game when there's a laggy scene (and definitely put the tech used in my blacklist).
- pjmlp 4y agoI have the same happening to me with C and C++ games, so it isn't a given that the language along is the cause, rather the ability of the programmers.
- jcelerier 4y agoThe very vast majority of native games I played don't have the kind of lag that unity games have (and seem to do much more things). Only very bad one I could remember was Neverwinter nights 2.. that one was really unplayable even on god-tier computers
- pca006132 4y agoI guess the problem is usually not about 1% throughput, but about where the 1% is and how it affects the latency. You can have the 1% overhead evenly distributed which is normally fine, but you can also have a latency spike for some operation (and I guess this is the case for barriers), which IMO really hurts in some cases.
- hayley-patton 4y agoBarriers are probably too small to cause latency spikes. The object logging barriers are a bit complicated, as they write an object into a thread-local log and infrequently have to get more memory for the log. But a card barrier is rather simple, and could look like SHR R_pointer, 9 AND R_pointer, <cards> MOV BYTE [R_cards + R_pointer], 0 where <cards> is one below an immediate power of two number of cards, each card covering 2^9 = 512 bytes of heap. This is roughly the write barrier in SBCL on x86-64; there isn't much of a reason to think it will cause a latency spike. On the other hand, "Barriers revisited" does mention a pathology about how cards can introduce false sharing, but that's still more of a smear than a spike.
- mrighele 4y ago1% Less servers in the farm means 1% less expenses on the server farms. That is a lot only if the server farm is your main cost and you run on thin margins. My guess is that it is not that big of a niche, although the players are probably big
- WalterBright 4y agoIf you look at the revenue cloud service providers get, and that revenue is based on CPU time used, 1% is a huge amount of money. It's like weight on an airplane. Boeing told me back in 1980 that saving one pound was worth a quarter million dollars of investment. That'd be like a million bucks today.
- darksaints 4y agoThere are massive python and bash codebases used at all of the major cloud service providers. And none of the cloud service providers are using custom-compiled PGO-optimized OSes specifically optimized for the exact architecture and instruction set and resource set that they will be deployed on, despite >1% performance advantages for doing so. Because sometimes the complexity of doing things the fastest way possible is not worth the performance improvement. The boeing example is illuminating. One could conceive of infinite possibilities where it would be better to spend the extra million dollars than to get something that saved a pound but didn't meet other project requirements. What good would it be to buy a $1M cheaper 747 if the landing gear broke on each landing? Everything is a tradeoff, even things that are extremely important like weight on airplanes or runtime performance in computers.
- nequo 4y ago> if your hedgefund trading software runs 1% faster Jane Street has used OCaml for about 20 years. Last year, OCaml merged an improvement to its GC that reduced latency by 75% (by one measure), and reduced execution time by 23% when compiling OCaml and around 6 to 7% when compiling Coq libraries: https://github.com/ocaml/ocaml/pull/10195#issuecomment-896150306 https://github.com/ocaml/ocaml/pull/10195#issuecomment-89615... Performance is definitely left on the table even in mature and mission-critical software.
- WalterBright 4y agoHedge fund traders are using D, for performance. I've even had a hedge fund trader come to me to teach them how to implement their own compiler, as they wanted to make it faster. Remember the stories about traders trying to shave milliseconds off of their trading speed?
- deleted 4y ago[deleted]
- tptacek 4y agoFinance shops use everything. The exchanges themselves are, or were last time I worked on anything there, built largely out of Java.
- kasey_junk 4y agoMilliseconds is at least 20 years out of date. Last I worked in the industry we measured our latency in micros and that was 10 years ago. Even then anyone that actually cared about latency never left the switch, all fpga & asic. I even met a hedge fund that ran their back test platform mostly on hardware because it allowed them to run more tests, which was a strategic advantage. That said, 1% for free makes the ghost of Admiral Hopper happy and that’s reason enough for all of us.
- throwaway894345 4y agoI mean, 1% is fine if it comes with no other tradeoffs, but that's probably not the case. I would trade a 1% improvement in performance for a 1% improvement in developer productivity almost every single time (very rarely are businesses performance constrained such that they can afford to slow development for marginal performance deltas), and when you're operating near the margins of performance, it's usually more likely that you'll have to halve productivity to eek out a small amount of performance improvement.
- vanderZwan 4y agoI'm sure the creator of D knows what he's talking about, but doesn't that depend on how much is gained elsewhere?
- WalterBright 4y agoIt does. D offers a mix of manual and gc allocating, and the people who want higher overall performance lean towards more manual. Any penalty that applies to pointer code then gets amortized against less use of the gc. It's a different tradeoff if the languages primary allocation scheme is GC.
- zozbot234 4y agoThe obvious approach to that issue is to support garbage-collected objects as a special address space within the program. You could use normal read-only pointers to address these, but write pointers to them would be specialized and incur that memory barrier overhead.
- WalterBright 4y agoThere's an API call into the GC that does just that, tell you if it points into the GC pool or not. Unfortunately, it's not fast enough.
- zozbot234 4y agoWhy does this have to be a runtime check? Perhaps the compiler could optimize pointer writes that can be proven not to affect garbage-collected objects, by dispensing with the memory barrier overhead for those.
- titzer 4y agoIt's possible to lose 5% from a single bad register allocation decision.
- zozbot234 4y agoRegister allocation is an NP-hard problem. It's not feasible to reach a single "good" decision, you'll always have to choose how much compiler time should be assigned to it, and what heuristics to use.
- hayley-patton 4y agoTo "lose" 5% I imagine one has to only be "worse" than some other heuristic that they measured the results of.
- chrisseaton 4y agoThis isn’t a problem in practice - you don’t need a single best solution, because you can get a good-enough solution very easily - linear scan. Classic example of an over-theorised problem.
- IshKebab 4y agoAre you really saying that a 1% performance loss makes something "not a systems programming language"? Of all the weird definitions of "systems language" I've heard this has to be the weirdest. 1% compared to what? Hand-written assembly? C? C++? Clang and GCC differ by way more than 1% in most benchmarks. Does that mean that one of them can't compile system languages or something? I mean, I would agree that there definitely is a performance threshold below which you wouldn't consider a language a "systems language" - i.e. it would be silly to write an OS in the language. But 1% seems at least an order of magnitude off.
- optymizer 4y agoI see D as a non-compromising language (in terms of eating your cake and having it too) and that's why I like it. I think the authors don't want to limit its performance at the design level. For equivalent code, they don't want it to only ever be able to run 99% as fast as C, they want it to be able to run, at least theoretically, as fast as C or better. That's probably where the 'systems language' comparison came from. In practice though, I'm willing to bet DMD,GDC and LDC result in more than 1% difference in performance (but that's just speculation).
- WalterBright 4y agoAll those 1%'s add up.
- slashdev 4y agoIt's not a big deal. People give up more than 1% in suboptimal compiler flags alone. People give up far more than that by using unoptimized or lightly optimized code. People give up more than that by being too lazy to use profile guided optimization. Or by using the system malloc. To say that a 1% loss in performance disqualifies something as a systems language is absurd.
- mumblemumble 4y agoOne important difference in all of those is that they are decisions made by the user of the programming language, not the author. Sub-optimal performance decisions made by the user are their own business (and, perhaps, their customers'), and not really the language authors' concern. The converse is not true. Sub-optimal performance decisions made by the language authors end up affecting everybody. I agree that saying a 1% difference would disqualify it as a systems language is hyperbolic. I disagree with the assertion that it's not a big deal. Having a core development team that considers 1% to be a big deal is a very desirable trait in a systems language. Achieving very high performance goals often comes through an accretion of many such 1% (and sub-1%) decisions.
- eloff 4y agoThe difference in performance between existing systems languages is greater than 1%. This is just not a big deal. People will not choose their systems language based on a 1% performance difference. It's so far down the list of considerations that it's a total non-issue.
- WalterBright 4y agoWould Linus accept a language for core Linux work that came with a 1% penalty?
- diffxx 4y agoThis question is impossible to answer in a vacuum. What if the language made developers 90% more productive or 90% less likely to introduce a memory bug or offered 3x faster compiler times? A 1% runtime performance hit would be well worth it if that were the case. Perhaps with the extra time available, developers could find better algorithms/ways of expressing their programs that would ultimately lead to faster runtime performance on average even with the 1% hit in certain microbenchmarks.
- TheGag96 4y agoI'd probably go even further and say that if there's any hidden check or restriction on reading or writing from a pointer, then it's not a systems language. I'm glad D does not have anything like that.
- throwaway894345 4y agoThat seems like a pretty arbitrary definition of "systems language". Lots of hidden stuff happens in "systems languages"--compilers do unintuitive magic all the time, and the languages themselves have their own runtimes.