Options

[Programming] Reinventing equality, one language at a time

134689100

Posts

  • Options
    NaphtaliNaphtali Hazy + Flow SeaRegistered User regular
    edited July 2017
    This is kind of an oddball question. I'm dealing with a pretty simple Historian SQL table but has potentially many, many records and it doesn't seem to be optimized for searching against the timestamp column terribly.

    Is there a more efficent way to search for the first record that occurred before a specific timestamp than doing something like
    SELECT TOP 1 timestamp, value FROM tbl1
    WHERE tagname = 'tag1' and timestamp < '2017-07-24 12:00:00'
    ORDER BY timestamp DESC
    

    I've tried playing around with max(timestamp) in a different version of the query above and it doesn't seem to process timestamps correctly, constantly returning me a record in February instead of the one it should find that happened three days ago. I suppose I could constraint the start and end times it could ultimately search for in the table but the issue is the last previous record outside of the search timestamp could potentially be many months in the past. Changing the ordering is also giving it some overhead as well and I am no DBA or SQL ace so I wouldn't mind some help on this if anybody has previously tackled a similar issue..

    edit:

    Ended up solving it by leveraging some SET commands in historian SQL, changing it to search backwards from the starting timestamp.

    Naphtali on
    Steam | Nintendo ID: Naphtali | Wish List
  • Options
    crimsoncoyotecrimsoncoyote Registered User regular
    • Significant performance improvements on Windows, massively reducing initial load time and improving UI response for the vast majority of users during testing.

    Their definition of "significant" differs greatly from mine.

    Also, it locked up the 2nd time I opened it this morning. (old man yelling @ clouds) See, this is what happens when you give OSS devs a GUI to build.

    Windows has been failing to boot on my home machine since the last update. With Microsoft's new update policy and how buggy Windows 10 seems to be, I never know if my hardware is failing or if Windows 10 is just fucking with me.

    Thanks, Microsoft!

    Edit: By failing to boot, I mean sometimes the computer will start and everything is working fine, but my display will just fail to turn on. Everything else appears normal and it POSTs fine.

    Hey I think I have this issue, too!
    Like it will boot up and the screen will be blank. Usually works fine on reboot.

  • Options
    gavindelgavindel The reason all your software is brokenRegistered User regular
    I either have a system breaking bug of catastrophic proportions...or a false positive test failure. Which one? Why not both? :bzz:

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Wow, Go has a weird way of parsing strings to a Time. I mean, it makes sense, it's just weird.
    layout := "2006-01-02 15:04:05.999999999 -0700 MST"
    t, err := time.Parse(layout, value)
    

    You define a layout matching the string you're trying to parse a time/date from. You need to use those exact values for day/hour/year/minute etc, because that's what Go looks at to map values in the string against.

    The mnemonic is that the base string is " 01/02 03:04:05PM '06 -0700", but honestly I just get more confused by "15:04" than "H:m".

  • Options
    InfidelInfidel Heretic Registered User regular
    Echo wrote: »
    Wow, Go has a weird way of parsing strings to a Time. I mean, it makes sense, it's just weird.
    layout := "2006-01-02 15:04:05.999999999 -0700 MST"
    t, err := time.Parse(layout, value)
    

    You define a layout matching the string you're trying to parse a time/date from. You need to use those exact values for day/hour/year/minute etc, because that's what Go looks at to map values in the string against.

    The mnemonic is that the base string is " 01/02 03:04:05PM '06 -0700", but honestly I just get more confused by "15:04" than "H:m".

    No, that doesn't make sense. :rotate:

    OrokosPA.png
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    There, wrangled it into an actual formatter.
    func FormatTime(value string) string {
    	layout := "2006-01-02 15:04:05.999999999 -0700 MST"
    	format := "Mon 15:04, Jan 2 2006"
    
    	t, _ := time.Parse(layout, value)
    	return t.Format(format)
    }
    

    :rotate: :rotate: :rotate:

  • Options
    zeenyzeeny Registered User regular
    Echo wrote: »
    There, wrangled it into an actual formatter.
    func FormatTime(value string) string {
    	layout := "2006-01-02 15:04:05.999999999 -0700 MST"
    	format := "Mon 15:04, Jan 2 2006"
    
    	t, _ := time.Parse(layout, value)
    	return t.Format(format)
    }
    

    :rotate: :rotate: :rotate:

    Your function is swallowing errors.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited July 2017
    Yes, I tend to leave that out when posting sample code.

    Echo on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    wondering if this is answerable by the resident C guys, even though it's ObjC I imagine the principle is the same

    do I incur any performance overhead by including extra headers in a given class?

    I'm getting to that point where I have some files which have dozens of imports and I want to clean it up with some consolidated import header files, but I don't know if that could potentially hurt my app by increasing memory overhead somehow

  • Options
    LD50LD50 Registered User regular
    In straight c I would think it would only have performance implications at compile time, but c doesn't have classes so I imagine it's different for objc.

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Compiler performance sure, though the parsers tend to be extremely efficient these days, files routinely pull in megabytes of headers. Runtime performance no, unless ObjC is weird or the linker is terrible enough to not prune unnecessary imports

  • Options
    LD50LD50 Registered User regular
    Phyphor wrote: »
    unless ObjC is weird


    I 100% agree with you, but the emphasis is mine.

  • Options
    bowenbowen How you doin'? Registered User regular
    yeah I doubt apple is pouring a ton of time into compiler optimizations, especially with swift around now

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    Oh look we're on Postgres 9.4.7 that doesn't support "if not exists" on "create index".
    DO $$
    BEGIN
        IF to_regclass('job_statistics_job_id_idx') IS NULL THEN
            CREATE INDEX job_statistics_job_id_idx ON job_statistics(job_id);
        END IF;
    END$$
    

    it's beautiful

  • Options
    htmhtm Registered User regular
    bowen wrote: »
    yeah I doubt apple is pouring a ton of time into compiler optimizations, especially with swift around now

    I guess it depends on what you mean by "compiler optimizations", but since they're one of the primary contributors to clang/LLVM (one of their ex-guys founded the project), they do a lot of work on C language stuff. In recent years, they've also been adding language features to Obj-C in order to make it play nicer with Swift. They also use C++ heavily internally. In fact, the Obj-C runtime was written in C++ the last time I checked (it's open source).

    Both iOS and macOS are effectively BSD distros, so as nice as Swift is, Apple's not going to be skimping on C and its kin any time soon.

  • Options
    djmitchelladjmitchella Registered User regular
    edited August 2017
    Why is my build not triggering when I change the source code, I ask myself? It says "enabled", right?

    xqSMBJo.png

    oh.

    thanks, TFS.

    (edit: no, I am dumb, it actually _does_ trigger when I change the source code, I'd just forgotten to include another path; if I want to disable it then I unslide that slider. It is still confusing, just in the other direction)

    djmitchella on
  • Options
    jothkijothki Registered User regular
    edited August 2017
    I've been learning Javascript/Typescript lately, and there are some things about it that are driving me nuts when I look at existing code. The most recent one is defining a constant class variable and then immediately changing the values of its members. I assume that it's a hidden pointer thing and that all it's doing is preventing the pointer as a whole from being reassigned to something else, but it's still giving me a headache.

    jothki on
  • Options
    LD50LD50 Registered User regular
    Yes, that is exactly what it is doing. The reference is a const, but the contents of the reference are not. If you really want the behavior you are expecting you can call freeze on the object, which will prevent any properties from being added/removed/changed.

  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    ahh

    doing my first load test on a server identical to my production environment

    load in a big batch of data... mostly goes fine... start visiting some pages, and I notice that the requests aren't... failing... or timing out... it just seems to stop serving the page abruptly at random points and random times

    odd

    this is all my first time in using django, nginx, gunicorn, postgresql, etc... so I jog through some theories about what might cause this behavior to begin my search

    nothing super obvious comes up in about 30 minutes of digging through config files (i had first suspected maybe a default setting in a part of the server stack was rate/size limited somehow)

    and then the most obvious answer dawns on me...


    > top

    ... Mem: ... 23M Free ...

    ah yes

    that... explains everything

    tomorrow, the great hunt to figure out where all my memory went

  • Options
    LD50LD50 Registered User regular
    25M ought to be enough for anybody!

  • Options
    NaphtaliNaphtali Hazy + Flow SeaRegistered User regular
    64k is all you'll ever need

    Steam | Nintendo ID: Naphtali | Wish List
  • Options
    jaziekjaziek Bad at everything And mad about it.Registered User regular
    • Significant performance improvements on Windows, massively reducing initial load time and improving UI response for the vast majority of users during testing.

    Their definition of "significant" differs greatly from mine.

    Also, it locked up the 2nd time I opened it this morning. (old man yelling @ clouds) See, this is what happens when you give OSS devs a GUI to build.

    PgAdmin 4 has got to be the worst UI I have ever used, bar none. I don't understand how you can release something so obviously broken, and regressed from previous versions, with a straight face.

    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    Oh god no

    I think... I think one of our devs has been releasing some FPGA images that don't meet worst case fMax under some conditions.

    Their excuse: it's just the slow model that's failing.

    Quick link for those who are blessed enough to ignore fMax.

    Penny Arcade Developers at PADev.net.
  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Naphtali wrote: »
    64k is all you'll ever need

    And here I am sitting on 1k of FIR coefficients for just one of the digital filters in the system!

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Oh god no

    I think... I think one of our devs has been releasing some FPGA images that don't meet worst case fMax under some conditions.

    Their excuse: it's just the slow model that's failing.

    Quick link for those who are blessed enough to ignore fMax.

    Timing violations are great

    If you like nondeterministic builds

  • Options
    gavindelgavindel The reason all your software is brokenRegistered User regular
    Orca wrote: »
    Oh god no

    I think... I think one of our devs has been releasing some FPGA images that don't meet worst case fMax under some conditions.

    Their excuse: it's just the slow model that's failing.

    Quick link for those who are blessed enough to ignore fMax.

    Timing violations are great

    If you like nondeterministic builds

    Personally, I nondeterministic love builds.

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • Options
    dporowskidporowski Registered User regular
    gavindel wrote: »
    Orca wrote: »
    Oh god no

    I think... I think one of our devs has been releasing some FPGA images that don't meet worst case fMax under some conditions.

    Their excuse: it's just the slow model that's failing.

    Quick link for those who are blessed enough to ignore fMax.

    Timing violations are great

    If you like nondeterministic builds

    Personally, I nondeterministic love builds.

    Do you, really?

  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    i continue to be mesmerized by FPGA and wish i had a valid reason to ever try my hand with one

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Jasconius wrote: »
    i continue to be mesmerized by FPGA and wish i had a valid reason to ever try my hand with one

    It's interesting, but holy shit tooling is primitive. Like, if you thought embedded toolchains blow goats, you've never seen an FPGA build get an hour in and then fail. Or the build complete, but because you misspelled something it inferred a wire and you just broke the build.

    Ugh.

    And build times are atrocious.

  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited August 2017
    Whoever can solve the NP hard problem of FPGA fitting and thus get compile times down will earn millions.

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Options
    DrovekDrovek Registered User regular
    Orca wrote: »
    Jasconius wrote: »
    i continue to be mesmerized by FPGA and wish i had a valid reason to ever try my hand with one

    It's interesting, but holy shit tooling is primitive. Like, if you thought embedded toolchains blow goats, you've never seen an FPGA build get an hour in and then fail. Or the build complete, but because you misspelled something it inferred a wire and you just broke the build.

    Ugh.

    And build times are atrocious.

    I haven't played with FPGAs in ages. I have even been thinking of firing up an AWS EC2 FPGA instance to play around... But then I remember just what you said.

    steam_sig.png( < . . .
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited August 2017
    Drovek wrote: »
    Orca wrote: »
    Jasconius wrote: »
    i continue to be mesmerized by FPGA and wish i had a valid reason to ever try my hand with one

    It's interesting, but holy shit tooling is primitive. Like, if you thought embedded toolchains blow goats, you've never seen an FPGA build get an hour in and then fail. Or the build complete, but because you misspelled something it inferred a wire and you just broke the build.

    Ugh.

    And build times are atrocious.

    I haven't played with FPGAs in ages. I have even been thinking of firing up an AWS EC2 FPGA instance to play around... But then I remember just what you said.

    Oh my gosh

    I'm embarrassed to admit that I didn't know AWS EC2 FPGA instances were a thing!

    And they've done the tedious parts of hooking the FPGAs up to a PCIe bus, and adding DDR!

    This is weirdly awesome!

    Edit: Partially related: I tell you what though. I find that it's much easier (and more critical) to do unit tests because of the massive compile times.

    It's very easy to justify spending 2-4 hours writing extensive unit tests for a module, if those tests will save me 1-2 recompiles in the future.

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Options
    a5ehrena5ehren AtlantaRegistered User regular
    edited August 2017
    Sure would be nice if people at least compiled their code before pushing to master. Don't (clap) break (clap) the (clap) build (clap)

    a5ehren on
  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    We've gone with public shaming. If the master build breaks, whomever checked on the broken code gets to wear the hat of shame for the rest of the day or until someone else breaks the build.

  • Options
    a5ehrena5ehren AtlantaRegistered User regular
    Would be nice, but the guys who broke it are in a different country from me :P

    Even better, basically that whole office is on PTO today and off Monday, so they broke the fucking build for 4 days.

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Back out the changeset, send nastygram.

  • Options
    a5ehrena5ehren AtlantaRegistered User regular
    lol, it is actually 2 different commits that break the build in different places. Good work guys. You took the time to rebase, but couldn't bother to compile your code.

  • Options
    thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    a5ehren wrote: »
    Sure would be nice if people at least compiled their code before pushing to master. Don't 👏 break 👏 the 👏 build 👏

    Is your company big enough to invest in CI that leverages "git request-pull" in an automated fashion?

    Because that's civilization right there.

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    I've occasionally broken things by writing and testing code, reviewer requests changes, and either the requested changes were logically wrong or I just fat fingered and re-uploaded without checking

  • Options
    a5ehrena5ehren AtlantaRegistered User regular
    a5ehren wrote: »
    Sure would be nice if people at least compiled their code before pushing to master. Don't 👏 break 👏 the 👏 build 👏

    Is your company big enough to invest in CI that leverages "git request-pull" in an automated fashion?

    Because that's civilization right there.

    This project uses Bamboo, actually, but they don't have it setup to do real CI - just nightlies.
    Phyphor wrote: »
    I've occasionally broken things by writing and testing code, reviewer requests changes, and either the requested changes were logically wrong or I just fat fingered and re-uploaded without checking

    Yeah, I've done this as well but this particular repo does not have mandatory reviews on.

This discussion has been closed.