HNHacker News
TopNewBestAskShowJobs

Avernar

397 karma · joined November 5, 2014

submissionscomments
Avernar··on Dealing with insubordination
> scrum master

Your development process is based on micro management...

> hours to resolve a stylistic difference

so it's not surprising that there are debates about the one thing the devs have control over.

Avernar··on FCC approves ATSC 3.0, a TV technology with better pictures but less privacy
I would have returned that crap back to the store so fast it would make the sales person's head spin.
Avernar··on Why Go and Rust Are Not Competitors (2015)
As a C/C++ developer that doesn't surprise me at all. I looked at both Go and Rust and I'd go with Rust if given a choice between the two.
Avernar··on Red Hat Introduces Arm Server Support for Red Hat Enterprise Linux
Yeah, I'd love to get a couple of ARM servers for home use.
Avernar··on Teenage schoolgirl 'electrocuted after rolling on to iPhone cable in her sleep'
> It only takes 100 or 200 mA to kill.

Only if it reaches your heart.

Avernar··on Firefox 57.0 Released
> If you want to contribute to the DevTools themselves

I wish I had the time. So I'll have to wait for someone else to add the element DOM properties tab in thr panel that has the style rules and layout. Firebug had it, Chrome has it.

The right click and then Show DOM Properties with the results in the console pane is just painful to use.

Avernar··on Is it time to stop trusting Google search?
For me lazy has nothing to do with it. Usually one or more of the following:

* You have to navigate a half dozen pages to get to what you want assuming you can navigate the maze of links.

* Site search incompletely indexes the site.

* Site search has poor ranking. Twenty pages of press releases and other crap mentioning what you want before the actual info.

* Site search doesn't handle spelling mistakes so you get no results.

* Site search doesn't handle related topics so if you search for the wrong or alternate phrase you miss what you need.

* No site search feature at all.

So yeah, search engine is my first choice.

Avernar··on The Lost Art of C Structure Packing
If you are writing normal code then yes. But there are always exceptions.

One is trying to learn how your current target architecture actually works. This is not production code. It's a "where in memory did the compiler decide to put that" question. You may get the results you expect or you may get someting totally bizzare. But since the purpose is discovering how the compiler works there is no wrong result.

Another is if you are writing your own memory manager. Here there are a lot of pointer comparisons to not the same allocated objects. But a memory manager is very OS and architecture specific so you will probably have to rewrite it when porting the code.

Having said all that, I wouldn't subtract the two void pointers like the example did. I would have converted them both to integers first and then subtract. Again, since this is for debugging and/or learning purposes then it's OK to bend the language rules a bit.

Avernar··on Users don’t need a password
Hell no. And If I'm forced to I'll reroute it to email anyways.

I frequently don't have cell coverage but do have WiFi.

Avernar··on Unbalanced reads from SSDs in software RAID mirrors in Linux
I may have misread your original post but your hostility isn't helping to clarify things. Instead of replying back "I was talking about the SSD cache" you replay back with "Well, it could hardly be below, could it. Was there an insight you wanted to mention?" So instead of clarifying things you decided to be rude.

Now that I know what you're talking about, let's try to answer your question. There are SSD controllers that don't use a RAM cache on the drive. It's not necessary for performance and doesn't do as much as on a HDD if present. The main benefit of a drive cache while reading is for read ahead. This is not needed for an SSD as it doesn't have to wait for the sectors to show up under the head.

The only thing that will affect things is reading file system blocks from the same SSD page/block. The md code already does this. If the next block requested is after the last blocks read it will use the same SSD.

If the block is from somewhere else then it doesn't matter if it comes from this SSD or that SSD. Access time will be the same.

Avernar··on Unbalanced reads from SSDs in software RAID mirrors in Linux
One benefit of spreading out reads is detecting bad sectors on the drives that were normally not going to see much reads. Then the good data can be copied from the other mirror.
Avernar··on Ask HN: How common is a counteroffer for developers who give notice?
> you negotiated some terms mutually

Most people are not skilled negotiators. That aside, the balance in that negotiation is in favour of the employer at the start. At that point you are worth nothing to them. They can just go to the next candidate. You on the other had have a mortgage, debts to deal with, bills to pay, family to feed, etc. It takes time before that balance tips towards the employee. That's when the company needs to reassess what they're paying you.

> There’s no bluff being called.

They know you're worth more but at your yearly performance review they'll do their damnedest to only give you cost of living if even that. Then they put the burden on you to prove you're worth more than that. "What did you accomplish this past year?" They know what you did for them. They're hoping you were too busy to document it yourself. "We can give you more but you have to take on more responsibilities." They were paying you less than you were worth for your current workload before this! This extra work will mean even more unpaid overtime which will nullify the raise and even turn it into an effective pay cut. Even if you do manage to document your past work and/or agree to more work you'll just hit the arbitrary raise cap they put in place. "This is the best that we can do."

They are bluffing. They're gambling that you can't find a better offer. Or that it's too much hassle to switch. But once you call their bluff that's when you get to finally see what they really could have been paying you.

> act rationally and in their best interests

Companies very rarely do this for long term goals. Short term gains is top priority. Saving money on payroll now is better to them than mitigating the big financial loss that loosing a key employee would cause in the future.

That is the reason why we see this counter offer behaviour each and every time. You've change the "he's going to quit sometime in the future" to "he's quitting NOW". You've now made it a short term issue and that's what finally got them to react.

Avernar··on Unbalanced reads from SSDs in software RAID mirrors in Linux
Let me clarify. All the VFS caches are above the md driver. The cache we care about, the buffer cache, is not below the md driver.

You'd need some kind of cache below the md driver to cache "metadata relevant to the SSD innards". Since there isn't one therefore there can't be a penalty due to caching to switch between SSDs in a mirror. That answers your question.

But since you want an insight, here's one for you. There is no "metadata relevant to the SSD innards" available. The md drivers do not have this information. I wish they did. When I was still playing with the md code I'd love to know the block and page sizes of the drives. But that information is two bytes. Not really something that would need a cache.

Avernar··on Unbalanced reads from SSDs in software RAID mirrors in Linux
Back when I still ran Linux on my personal servers I noticed this. I was adding TRIM support to the md drivers before the maintainers finally got around to it. That's when I noticed the balancing code tended to favour one disk.

I added round-robin code and experimented with splitting large sequental requests between idle disks.

Avernar··on Unbalanced reads from SSDs in software RAID mirrors in Linux
The FS cache sits above the raid driver.
Avernar··on Ask HN: How common is a counteroffer for developers who give notice?
To me a counter offer is basically saying "we got away paying you less than what you're worth to us and you finally called our bluff". That's why I'll never accept a counter offer.
Avernar··on The Curious Case of the Longevity of C
I always wished C gave access to the overflow and carry flags. Would have made a lot of things simpler.
Avernar··on Why undefined behavior may call a never-called function
Thanks. I'm glad some people are getting some use from my posts.

I'm used to the "religious" attacks against me as this isn't the first time it's happened. You need to have a thick skin to post the non-mainstream ideas here. It doesn't matter if you are correct or that your idea is technically accurate, it's all about the how popular the other view is.

The funny thing is how consistent the pattern is. First you see the downvotes and upvotes come in. This is the first sign you're on a hot button topic. Then people will simply tell you that you're wrong without any counter argument. Once you respond back with further facts to back up your argument the attacks on your education/skill/knowledge come in. You misused some cargo cult terminology and that's proof you don't know what you're talking about. Usually it ends there but once in a while someone starts up with the personal insults.

It's funny and sad watching the same thing happen over and over. Sigh.

Avernar··on Why undefined behavior may call a never-called function
>> if it was smart it would have figured out that the value never was initialized

> But that's false

Are you reading the same code the rest of us are? NeverCalled is never called. So Do is not explicitly initialized and therefore contains a null pointer because it's a static variable.

Now compiler writers wanted their benchmark scores better so instead of crashing the program when Do is called, which happens in the unoptimized version, they decided to play fast and loose with UB. They just made code vanish.

What I'm saying is that if the compiler can figure out that NeverCalled is actually called from somewhere then it's free to make these optimizations. But if it knows it's not called then it should either disable the optimization for that statement or better yet give a warning.

> There's nothing stopping this from being linked into a binary which doesn't even call main, or which calls NeverCalled, etc.

Which is why I called for Whole Program Optimization to solve that issue. Since it looks like you did not bother to find out what that is and how it would solve that issue I'll explain it here. In Whole Program Optimization the compile is pushed down to the link phase. This lets the compiler see the who program and apply optimizations globally instead of at a file by file bases. So it can tell if main is never called or if NeverCalled is called or not.

> And I bet you will also insist stamping your feet

Now you're attacking me instead of my arguments. Do you wish to have a civilized discussion or just resort to insults? Because if it's the latter I will just ignore you in the future.

> which just goes to show that the compiler writers know way more about this than you do

> You know nothing, but you're convinced you know so much more than those stupid compiler writers.

I am a compiler writer so I do know what I'm talking about. It's a small personal project but it means I've been doing a lot of thinking and research about compilers. And eliminating UB is my current design focus.

And if you reread what I wrote you can see I never called them stupid. They are quite smart and know what they are doing. But even a smart person can make bad decisions depending on their motivations. What I'm saying is that they are putting their skill towards exploiting UB instead of protecting programmers from it.

Avernar··on Why undefined behavior may call a never-called function
> It's really nice to be able to use abstractions that cost nothing because the compiler is smart.

But the compiler is not smart. It's screwing up in certain cases. In this example if it was smart it would have figured out that the value never was initialized.

> In this particular case, you might have a function pointer that exists for future expansion, but which currently only ever holds one value.

Then define it as a regular function for now. The fact that you only thought of one function that needs it means you're making abstractions before you really needed them. And if you need a second function soon you'll loose the speed of the optimization anyways. And you did profile it first to figure out that this one tiny optimization actually matters, right? :)

But let's say you really needed to do it that way for whatever reason. If the compiler was smart enough to warn you that it wasn't initialized you could have made an empty function and initialized it to that. Problem solved and the compiler would be free to optimize it away.

> In a case like that, it's really nice if the compiler can remove the indirection (and potentially go further and do clever things like inline the callee or do cross-call optimizations).

Sure. Do a full program optimization and figure out that the function to initialize the pointer was actually called. Then do all those clever optimizations. The issue is that the compiler writers want the benefits of the optimization without doing the work making the optimization safe by making the compiler smarter. They just hide behind the "undefined behavior" mantra and let the programmer pick up the pieces when it goes wrong.

> For this particular scenario, the language should encode the nullability of Do as part of the type. If it's non-nullable, then it should require explicit initialization.

This. I 100% agree that this is the proper solution. But it would require a whole program pass to figure out that it's actually initialized somewhere. As I said above, the compiler writers could have done that without a change to the language.

But a lot of UB could be avoided by language changes. That's what many people have done when designing new languages. With C however we're stuck with what we have and need to make the compiler smarter before it slaps every optimization in its tool belt at every piece of code.

Maybe the C language needs to slowly evolve and add those changes to start getting rid of UB. But there has been zero progress in that direction. The compiler writers are perfectly content to squeeze out every last cycle of performance using any new UB loophole they can find.

When safety finally becomes a priority to them over benchmarks then maybe we'll start seeing some progress.

Avernar··on Safari is the new IE
Safari is full of bugs and incompatibilities. Every time I develop something for the web it's always "works on Firefox, works on Chrome, works on IE/Edge and works on... Nope! Something broke on safari again."

And the thing that bugs me the most about it is that it's tied to the iOS version you have on mobile. Eventually you're prevented from upgrading it because your device doesn't support the new iOS version.

Avernar··on How Python does Unicode
Ah, I see. I agree that it would be a bad idea to give acess to the UTF-8 representstion.

As for length in bytes, a good way to handle most use cases regarding that is to have a function that truncates the string to fit into a certain number of bytes. That way you can make sure it fits into whatever fixed buffer and the truncation would happen on a grapheme level.

Avernar··on How Python does Unicode
Change case, yes, that would require actually decoding the string to the unicode type. But that could be done when needed and not every time something from my databse needs to go out to the client.

Slicing works fine on a UTF-8 string as I'm slicing between ASCII characters which don't appear inside a non ASCII character. If I needed to slice between certain code points it would still be easy as I just look for the appropriate 2-4 byte sequence and slice before or after it. Python doesn't support graphemes so can't do much with those.

Measuring length is not something that comes up for me. And indexing to an absolute spot in a string never comes up at all.

But yes, if I did have to call a text processing library I'd have to then encode/decode to the Unicode type. But that's rare enough that I can keep everything UTF-8.

Avernar··on How Python does Unicode
But that's the same for UTF-16 and UTF-32. That's why I was wondering why you singled UTF-8 out, implying it needed extra handling.
Avernar··on How Python does Unicode
That's why the search functions need to be more intelegent. If you pass the search function a grapheme it will do more work. If it notices you just passed in a grapheme that's just a code point it can do a code point scan. And if the internal representstion is UTF-8 and it sees you passed in an ASCII charzcter (very common in lexing/parsing) it will just do a fast byte scan for it.

Now if the spec thinks identifiers are just a collection of code points then it's being imprecise. But things would still work if the lexer/parser you wrote returns identifiers as a bunch of graphemes because ultimately they're just a bunch of code points strung together.

It's only in situations where you need to truncate identifiers to a certain length that graphemes become important. Also normalizing them when matching identifiers would also probably be a good idea.

Avernar··on How Python does Unicode
I'm not advocating that the programmer needs to implement the iterators but that the language/runtime have built in support for them.

As for searching for ASCII, which is prevalent in parsing, the iterator function to find the next specified character can do a low level and fast byte search. That's one of the benefits of UTF-8, searching for ASCII characters is super fast.

You wouldn't have to do the character position on each advance. Just have a beginning of line iterator that's updated every time you see a newline character and on error you do call a function that gives you how many characters between the current position iterator and the start of line iterator.

Working with iterators is no more coplex than working with indexes. But it's the language that needs to provide them.

Avernar··on An Opinion in Defence of NATs
When you get multiple devices that require the same inbound ports (game consoles are a good example) you can open the same port for each device.
Avernar··on An Opinion in Defence of NATs
But you can open a large range of ports to multiple devices. For a game console you can allow UDP 1024-65535 without issue.

And if you have multiple devices that use the same port you can open that port on each one. No need for an external server to look up what port the device can be reached on.

Avernar··on How Python does Unicode
You might be correct and 32 bits could have been enough but Unicode has restricted code points to 21 bits. Why? Because of stupid UTF-16 and surrogate pairs.

I'm curious why you think that UTF-8 requires complicated lookup tables.

Avernar··on How Python does Unicode
Semantically equivalent yes, access time equivalent for variable width strings no. One of the reasons for Python 3's odd internal string format is because they wanted to keep indexing and have indexing be O(1). The reason why I think replacing indexing with iterators is that it removes this restriction and they could have made the internal format UTF-8 and/or easily added support for graphemes.

I prefer to have a system where 100% of the cases are valid and teaching people corner cases is not required. We all know how well teaching people about surrogate pairs went. And we're not forbidding the 99.99% case but providing an alternative way to accomplish the exact same thing. The vast majority of code uses index variables as a form of iterator anyways so it's not that big of a change.

The main reason people keep clinging to indexing strings is that's all they know. Most high level languages don't provide another way of doing it. People who program in C quickly switch from indexing to pointers into strings. Give a C programmer an iterator into strings and they'll easily handle it.

← PreviousPage 2 of 9Next →