|
Qwertycoatl posted:I wonder what maintenance problems you get with a giant struct that you don't get wth 26 somewhat less giant structs grouped by name rather than purpose. It looks like they did it this way so each struct can have its own magic-number sentinel value at the end, letting them check (at runtime) to see whether the struct definition and and its initializer list have gotten out of sync i guess that's easier than figuring out which entry in a multi-hundred-line struct is missing but it still seems like it could be replaced by a compiler warning flag? from decl.c: C code:
C code:
RPATDO_LAMD fucked around with this message at 20:43 on Jan 19, 2023 |
# ? Jan 19, 2023 20:37 |
|
|
# ? Jun 8, 2024 06:00 |
|
QuarkJets posted:lmao The real coding horror is me, because as it turns out , this package is a wrapper for another client, (because we layer on some extra functionality to these API calls), so in FACT, it looked like this: Python code:
I discovered this, of course, after totally rewriting our test suite in PyTest and moving all the tests over and rewriting them. So...wasted a few hours, but not that big of a deal, and things are nicer now. I think I might update that attribute to have an underscore so it's easier to notice, since it's not intended to be exposed. It's almost like 'private' variable nomenclature works sometimes.
|
# ? Jan 20, 2023 02:28 |
|
Sorry but those tests are still dumb as hell. A method that simply delegates to a different method with no actual logic of its own does not need to be tested. If the method does contain logic, then the tests should actually exercise that logic.
|
# ? Jan 20, 2023 02:42 |
|
This seems like the place for this email I got, despite it not being strictly coding:quote:Dear Franchise Fans, dougdrums fucked around with this message at 04:18 on Jan 20, 2023 |
# ? Jan 20, 2023 03:50 |
|
Given that the initial cause is mentioned as "file server storage reaching max capacity", a playbook entry of "file server is full -> delete older backups to free up space" is pretty easy to imagine.
|
# ? Jan 20, 2023 03:59 |
|
Ah that makes sense, but I can’t help but to imagine a few more steps in between there. I can kinda imagine being cheap enough that the answer isn’t throw more money at the cloud until the cause is figured out. Still scratching my head at “unutilized legacy code” though.
|
# ? Jan 20, 2023 04:05 |
|
https://twitter.com/steveklabnik/status/1616157231421980694
|
# ? Jan 21, 2023 00:14 |
|
https://twitter.com/i2talics/status/1615465332382081024
|
# ? Jan 21, 2023 00:18 |
|
i always thought the original was Fine, but the more alternatives i see the more convinced i become that it's not merely Fine, but actually superior
|
# ? Jan 21, 2023 13:09 |
|
I would use a switch expression:C# code:
|
# ? Jan 22, 2023 00:17 |
|
LongSack posted:I would use a switch expression: That's identical to the original dutch-government thing that set this discussion off
|
# ? Jan 22, 2023 00:20 |
|
https://twitter.com/TyrannoSaurav/status/1615492525997035521 Yeah, you should try to optimize it this way instead.
|
# ? Jan 22, 2023 06:39 |
|
RPATDO_LAMD posted:That's identical to the original dutch-government thing that set this discussion off fwiw the compiler actually eliminates the unnecessary comparisons in this case.
|
# ? Jan 22, 2023 10:00 |
|
This was more or less the solution I came up with as well and it's probably a sign I've been in kernel space for too long. The other was slightly more lines but involved constructing the string one codepoint a time on the stack to save memory.
|
# ? Jan 22, 2023 10:14 |
|
brap posted:fwiw the compiler actually eliminates the unnecessary comparisons in this case. Does it? Like, it could in this case, but I’d be kind of surprised if they bothered to implement that, given that it’s only possible in certain specific situations and the benefit is likely to be insignificant unless there are vast numbers of cases.
|
# ? Jan 22, 2023 18:27 |
|
It falls out of any basic CSE / GVN optimization to the point that it would be weird not to do it. And eliminating redundant branches is a very worthwhile optimization in general; people tend to write a lot of redundant range checks, and reducing branch density is very good on modern processors.
|
# ? Jan 22, 2023 18:39 |
|
rjmccall posted:It falls out of any basic CSE / GVN optimization to the point that it would be weird not to do it.
|
# ? Jan 22, 2023 18:49 |
|
rjmccall posted:It falls out of any basic CSE / GVN optimization to the point that it would be weird not to do it. And eliminating redundant branches is a very worthwhile optimization in general; people tend to write a lot of redundant range checks, and reducing branch density is very good on modern processors. ... How does NaN handling work out for that? I guess it follows from reasoning like: (percentage <= 0.2) implies percentage is not NaN !(percentage <= 0.1) and percentage not NaN implies percentage > 0.1 ? ...which seems annoying, but I guess you gotta do it for this stuff to be useful for FP. (And the evil --ffast-math from gcc might elide needing to prove !NaN?)
|
# ? Jan 22, 2023 18:51 |
|
Dijkstracula posted:this is all correct of course - though, the original method was written in Java and I've had cases where I wanted something along the lines of value numbering to be applied, but only the server compiler actually did it when I inspected the assembly. (maybe getPercentageRounds() is called often enough that it trips the recompilation threshold though ) Yeah, in Java you definitely get some weird threshold effects because there’s do much abstraction that’s relatively difficult to break through — to see through a trivial getter, the JIT has to devirtualize and inline, and devirtualization in particular is usually a speculative optimization which the client JIT is tuned against doing. final helps a lot. OddObserver posted:... How does NaN handling work out for that? I guess it follows from reasoning like: In general, the biggest problem with optimizing FP is definitely that a lot of things which seem obvious mathematically turn out to be contingent or outright wrong because floating-point math is weird. So floating point comparison is only a partial order because of NaNs, which means we have transitivity between ordered values (thus e.g. knowing x < 1.0 and 1.0 < 2.0 implies x < 2.0), but negated transitivity is contingent on knowing that the values are ordered. But yeah, you have to teach the optimizer this stuff to do anything with FP at all, and FP code tends to be hot and very usefully optimizable.
|
# ? Jan 22, 2023 19:19 |
|
rjmccall posted:final helps a lot.
|
# ? Jan 22, 2023 19:28 |
|
Dijkstracula posted:this is all correct of course - though, the original method was written in Java and I've had cases where I wanted something along the lines of value numbering to be applied, but only the server compiler actually did it when I inspected the assembly. (maybe getPercentageRounds() is called often enough that it trips the recompilation threshold though )
|
# ? Jan 22, 2023 19:36 |
|
Dijkstracula posted:mad that it never occurred to me to mark all those temporaries as final If they’re locals, it shouldn’t make a difference, that’s not an abstraction the optimizer needs help with. That’s just JIT tuning working against you.
|
# ? Jan 22, 2023 19:56 |
|
Volte posted:It clearly specifies that the original method was written in C# though I'm not exactly what you'd call a "reader of tweets" (oops, fair cop) rjmccall posted:If they’re locals, it shouldn’t make a difference, that’s not an abstraction the optimizer needs help with. That’s just JIT tuning working against you. Dijkstracula fucked around with this message at 20:05 on Jan 22, 2023 |
# ? Jan 22, 2023 20:02 |
|
I think you're supposed to make the methods final, not the locals.
|
# ? Jan 22, 2023 20:26 |
|
yeah, for monomorphizing + inlining I could see that being true (for the situation I was thinking of it wouldn't, but it's certainly possible that I way overfit the thing I was thinking about to the discussion at hand )
|
# ? Jan 22, 2023 20:32 |
|
rjmccall posted:It falls out of any basic CSE / GVN optimization to the point that it would be weird not to do it. And eliminating redundant branches is a very worthwhile optimization in general; people tend to write a lot of redundant range checks, and reducing branch density is very good on modern processors. That’s happening at a lower level surely? I was talking about specifically the difference between the switch vs if/else chain, where I’d be surprised if the compiler emitted significantly different code for each.
|
# ? Jan 23, 2023 11:30 |
|
The actual bug (as in: the program returning a different thing than expected) is the length, right? The returned strings are of different length for different percentages, and _all_ results include the zeroes at the end. ... or is this me realizing that I should think about NAN more often..? That NAN-discussion earlier made me nervous. Wipfmetz fucked around with this message at 12:51 on Jan 24, 2023 |
# ? Jan 24, 2023 11:21 |
|
both, but if you know that the output string is X chars long, you can just treat the string as such... of course every variant I've seen so far handles NaN badly, because remembering NaNs sucks.
|
# ? Jan 24, 2023 15:34 |
|
I'd argue that having to know the intentioned length of a const char * - string would be a bug in itself, though. But ok, maybe it was at least documented and that screenshot cut off said documentation. Wipfmetz fucked around with this message at 10:19 on Jan 25, 2023 |
# ? Jan 25, 2023 07:21 |
|
https://rdrr.io/cran/spatialEco/src/R/hli.Rquote:tmp1 <- terra::terrain(x, v="slope", unit="degrees") * 0.017453293 when you're on "tmp7" I think it's time to use slightly more descriptive names
|
# ? Jan 26, 2023 23:01 |
|
Can't help but feel that you buried the lede by not including the indentationR code:
|
# ? Jan 26, 2023 23:32 |
|
I tried but forgot SA strips out whitespace in quote blocks
|
# ? Jan 26, 2023 23:34 |
|
Java code:
|
# ? Feb 17, 2023 23:41 |
|
Doom Mathematic posted:
A pretty prime code snippet there imo
|
# ? Feb 18, 2023 01:43 |
|
That number isn't even prime.
|
# ? Feb 18, 2023 03:40 |
|
Toshimo posted:That number isn't even prime. I am embarrassed I didn't notice the divisibility by 9 at a glance. It's rather guaranteed by the way the number was chosen.
|
# ? Feb 18, 2023 03:53 |
|
|
# ? Feb 18, 2023 04:47 |
|
OddObserver posted:I am embarrassed I didn't notice the divisibility by 9 at a glance. It's rather guaranteed by the way the number was chosen. it's divisible by 3 even without any context I'm gonna assume it's a sentinel value and whatever it's initialized to is arbitrary but that's maybe giving too much credit
|
# ? Feb 18, 2023 07:38 |
|
more falafel please posted:it's divisible by 3 even
|
# ? Feb 18, 2023 15:26 |
|
|
# ? Jun 8, 2024 06:00 |
|
hey now at least we can say it's probabilistically prime
|
# ? Feb 18, 2023 18:14 |