Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Xarn
Jun 26, 2015
Travis is basically dead nowadays, so let's remove it.

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Linked from that tweet is another delightful reference.

https://twitter.com/juliawritescode/status/1446270669843582976?s=20


pre:
    pub fn now() -> Instant {
        let os_now = time::Instant::now();

        // And here we come upon a sad state of affairs. The whole point of
        // `Instant` is that it's monotonically increasing. We've found in the
        // wild, however, that it's not actually monotonically increasing for
        // one reason or another. These appear to be OS and hardware level bugs,
        // and there's not really a whole lot we can do about them. Here's a
        // taste of what we've found:
        //
        // * #48514 - OpenBSD, x86_64
        // * #49281 - linux arm64 and s390x
        // * #51648 - windows, x86
        // * #56560 - windows, x86_64, AWS
        // * #56612 - windows, x86, vm (?)
        // * #56940 - linux, arm64
        // * https://bugzilla.mozilla.org/show_bug.cgi?id=1487778 - a similar
        //   Firefox bug
        //
        // It seems that this just happens a lot in the wild.
        // We're seeing panics across various platforms where consecutive calls
        // to `Instant::now`, such as via the `elapsed` function, are panicking
        // as they're going backwards. Placed here is a last-ditch effort to try
        // to fix things up. We keep a global "latest now" instance which is
        // returned instead of what the OS says if the OS goes backwards.
        //
        // To hopefully mitigate the impact of this, a few platforms are
        // excluded as "these at least haven't gone backwards yet".
        if time::Instant::actually_monotonic() {
            return Instant(os_now);
        }

        Instant(monotonic::monotonize(os_now))
    }

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Volmarias posted:

Linked from that tweet is another delightful reference.

https://twitter.com/juliawritescode/status/1446270669843582976?s=20


pre:
    pub fn now() -> Instant {
        let os_now = time::Instant::now();

        // And here we come upon a sad state of affairs. The whole point of
        // `Instant` is that it's monotonically increasing. We've found in the
        // wild, however, that it's not actually monotonically increasing for
        // one reason or another. These appear to be OS and hardware level bugs,
        // and there's not really a whole lot we can do about them. Here's a
        // taste of what we've found:
        //
        // * #48514 - OpenBSD, x86_64
        // * #49281 - linux arm64 and s390x
        // * #51648 - windows, x86
        // * #56560 - windows, x86_64, AWS
        // * #56612 - windows, x86, vm (?)
        // * #56940 - linux, arm64
        // * https://bugzilla.mozilla.org/show_bug.cgi?id=1487778 - a similar
        //   Firefox bug
        //
        // It seems that this just happens a lot in the wild.
        // We're seeing panics across various platforms where consecutive calls
        // to `Instant::now`, such as via the `elapsed` function, are panicking
        // as they're going backwards. Placed here is a last-ditch effort to try
        // to fix things up. We keep a global "latest now" instance which is
        // returned instead of what the OS says if the OS goes backwards.
        //
        // To hopefully mitigate the impact of this, a few platforms are
        // excluded as "these at least haven't gone backwards yet".
        if time::Instant::actually_monotonic() {
            return Instant(os_now);
        }

        Instant(monotonic::monotonize(os_now))
    }


Oh god, ye olde backwards running system clock. I've had to debug something like this.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


I'm surprised Rust doesn't have something like steady clock. That's been around in C++ for a while now and they could've ported it over.

I mean I guess technically this is like steady_clock, but they can do better.

repiv
Aug 13, 2009

I checked LLVMs implementation of steady_clock and all it does is call the system monotonic clock functions - the same ones Rust uses, and found often aren't actually monotonic

AFAICT the only difference is that Rusts version has a hard guarantee of being monotonic, even if the system implementation is broken, but the C++ version takes the systems "guarantee" of monotonicity at face value

repiv fucked around with this message at 20:19 on Oct 8, 2021

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


That's C++ for you.

Tei
Feb 19, 2011
Probation
Can't post for 3 days!
I like the C++ way.

I also like to see the world burn, no relation.

Volguus
Mar 3, 2009

repiv posted:

I checked LLVMs implementation of steady_clock and all it does is call the system monotonic clock functions - the same ones Rust uses, and found often aren't actually monotonic

AFAICT the only difference is that Rusts version has a hard guarantee of being monotonic, even if the system implementation is broken, but the C++ version takes the systems "guarantee" of monotonicity at face value

To be honest, to me that looks the correct approach. If the OS is not capable of doing its job (return an always increasing counter) then just file a bug against the OS. Or against the CPU. Rust seems to be going above and beyond of what an userspace application should be doing.

QuarkJets
Sep 8, 2008

Yeah I agree with that, but at the same time who has never said "let's at least implement a workaround on our end"? It's just weird to have the compiler fix this instead of implementing a library with the workaround function

JawnV6
Jul 4, 2004

So hot ...
"file a bug against the CPU"

how'd that work out for u

Absurd Alhazred
Mar 27, 2010

by Athanatos

JawnV6 posted:

"file a bug against the CPU"

how'd that work out for u

It did work the once...

csammis
Aug 26, 2003

Mental Institution

Tei posted:

I like the C++ way.

I also like to see the world burn, no relation.

This is a loving pro tier post, just outstanding :golfclap:

JawnV6
Jul 4, 2004

So hot ...
aha whoops, not supposed to talk about them

repiv
Aug 13, 2009

QuarkJets posted:

Yeah I agree with that, but at the same time who has never said "let's at least implement a workaround on our end"?

Yeah, especially for something like this which keeps coming up across multiple OSes and CPU architectures, and it's difficult to validate whether or not the issue has actually been 100% fixed. In one of those issues a user reported Windows taking two weeks to hit the bug.

Apparently Firefox has basically the same hack because they also kept running into monotonic timers going backwards.

OddObserver
Apr 3, 2009

repiv posted:

Yeah, especially for something like this which keeps coming up across multiple OSes and CPU architectures, and it's difficult to validate whether or not the issue has actually been 100% fixed. In one of those issues a user reported Windows taking two weeks to hit the bug.

Apparently Firefox has basically the same hack because they also kept running into monotonic timers going backwards.

Interestingly Chrome's implementation doesn't seem to have any hacks on POSIX[1], Mac (...or Fuchsia, but whatever), though the Windows one is pretty complex:
https://source.chromium.org/chromium/chromium/src/+/main:base/time/time_win.cc;drc=7b376aa2d32f7acac47aa7edbc50849f6b229e86;l=541

[1] https://source.chromium.org/chromium/chromium/src/+/main:base/time/time_now_posix.cc;drc=7b376aa2d32f7acac47aa7edbc50849f6b229e86;l=99

Foxfire_
Nov 8, 2010

It looks to me like that isn't about ensuring monotonicity. It's switching the timer source it uses if there is no high resolution timer hardware, or when it suspects that the windows HAL is using a non-processor TSC source (vista or modern windows when there are large numbers of cpus) because it'd rather have a faster call to a lower resolution/higher battery life timer.

The posix one is just system monotonic clock always, die if it's not available

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

QuarkJets posted:

Yeah I agree with that, but at the same time who has never said "let's at least implement a workaround on our end"? It's just weird to have the compiler fix this instead of implementing a library with the workaround function

I don’t think anyone’s fixing this in the compiler. The rust code here is in a library — one that comes with the standard distribution iiuc, but still, a library. And the LLVM implementation somebody was talking about is presumably in the libc++ library, not the compiler framework.

omeg
Sep 3, 2012

Timekeeping was a mistake.

NtotheTC
Dec 31, 2007



only if you ask... Nicely

Tei
Feb 19, 2011
Probation
Can't post for 3 days!

omeg posted:

Timekeeping was a mistake.

Yea!

the brain don't seems to need a clock to function, every part is working has fast (or slow) as it want to work and somehow getting results.

maybe is time we start building clockless hardware, with semaphores or queues or some poo poo instead of clocks

and if anyone want to store a date in a database, we just punch him in the face

Edit:
this is a silly joke, clocks make everything easier

Tei fucked around with this message at 07:30 on Oct 11, 2021

Beef
Jul 26, 2004
Clockless hardware exists. Famously you have Chuck Moore from Forth game designing some http://www.greenarraychips.com/

Arguably you could make dataflow processor architectures that are purely transport triggered, but I don't think that has been explored yet.

Qwertycoatl
Dec 31, 2008

Clockless chips are like holographic storage, for multiple decades there have been periodic articles talking about how amazing it's going to be, but it's never really happened.

Kazinsal
Dec 13, 2011

Qwertycoatl posted:

Clockless chips are like holographic storage, for multiple decades there have been periodic articles talking about how amazing it's going to be, but it's never really happened.

I remember when they were talking about holographic cards being a rewritable blu-ray competitor in the mid-2000s and it seemed like a far fetched idea that was way more Star Trek than realistic tech. A whopping 30 gigs on a single magic plastic card!

Well, now you can get a 32 GB USB drive with a ten dollar bill and still have enough change left over for a Costco hot dog, and I still don't have a pocket full of isolinear chips. :rip:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Tei posted:

Yea!

the brain don't seems to need a clock to function, ...

Technically correct, apparently

https://www.scientificamerican.com/article/your-brain-has-two-clocks/

repiv
Aug 13, 2009

https://twitter.com/Cor3ntin/status/1361105117303476224

two hours of build time spent instantiating std::unique_ptr? :stare:

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


repiv posted:

https://twitter.com/Cor3ntin/status/1361105117303476224

two hours of build time spent instantiating std::unique_ptr? :stare:

How many unique pointers could you possibly need or want?

Xarn
Jun 26, 2015
The combined cost of std::unique_ptr being very flexible and smart type, and having to instantiate templates in each separate TU.

I moved to a custom unique_ptr-like type that has none of the smart parts, and for my project it took 20% off compilation times. :v: (I also made it trivial-abi type under Clang)

Tei
Feb 19, 2011
Probation
Can't post for 3 days!
I am waiting for Go++.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

champagne posting posted:

How many unique pointers could you possibly need or want?

This is my pointer. There are many like it, but this one is mine.


e: That's what I like about C++. My computer gets faster, but my compiles still take an age.

Truga
May 4, 2014
Lipstick Apathy

ynohtna posted:

This is my pointer. There are many like it, but this one is mine.


e: That's what I like about C++. My computer gets faster, but my compiles still take an age.

this is still vastly preferable to the world of "but everything keeps running slower anyway" we seem to be heading towards. everything is lovely javascripts now and you need 300 megs of ram and 50 million clock cycles to display a line of text lmao.

Qwertycoatl
Dec 31, 2008

champagne posting posted:

How many unique pointers could you possibly need or want?

2704612, apparently

Spatial
Nov 15, 2007

I got a 3900X (24 threads) for compiling C++ code and I did not regret it lol

Absurd Alhazred
Mar 27, 2010

by Athanatos
https://twitter.com/woketopus/status/1447150924846313475

Tei
Feb 19, 2011
Probation
Can't post for 3 days!
Fortunaly PHP has escaped his creators and are in the hands of other people that know more than the original author. Unfortunaly PHP has no real identity, just copy what seems to work. It started with inspiration from Perl and Python, and C and C++, and now is trying to recreate Java, but worse.

I wish the maintainers had ideas of their own that where worth following to make the language a better PHP, with solid fundations and principles. But at least is now in the hands of competent people, I believe.

PHP as is now, in 2021, is a language that will hit you in the face you with a rolled newspaper if you try to go too clever with things like lambda functions. Like if the language is trying to tell you "Please write simple tame code that *everybody* can understand". But I think thats somewhat a low bar that need to be raised, more than enforced.

NtotheTC
Dec 31, 2007



Coding Horrors: I still don't find programming enjoyable

Qwertycoatl
Dec 31, 2008

This is my favourite thing about php

Xarn
Jun 26, 2015
That one is a classic.

Should I spend 5 minutes implementing actual hash function? No, let's just mangle all names to have a nice length distribution.

Votlook
Aug 20, 2005
If worse is better, then PHP is best.

Doom Mathematic
Sep 2, 2008

Tei posted:

just copy what seems to work.

Disgraceful! Unheard-of in programming! A recipe for failure.

Adbot
ADBOT LOVES YOU

Tei
Feb 19, 2011
Probation
Can't post for 3 days!

Doom Mathematic posted:

Disgraceful! Unheard-of in programming! A recipe for failure.

Cargo culting is not a recipe for failure. Its just mediocre with mediocre results.

And we are talking about a programming language. Is better if is made following a idea, so is easier to learn and remember.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply