News for hackers. Stuff that matters.
Re:fs.promises.readFile is 40% slower than fs.readFile by xiphias2 on Wednesday March 03, 2021 @05:11PM (#26335430)
What really disturbs me is this comment:

,,But no one said fs.promises.readFile should perform similarly to fs.readFile ''

I'm happy that it was downvoted at least, but there should be a better way to set expectations for excellence in development.

Re:fs.promises.readFile is 40% slower than fs.readFile by boring_twenties on Wednesday March 03, 2021 @08:54PM (#26337628)
I've posted about this before, but I know someone whose coworkers actually tried to defend themselves with "not leaking memory wasn't in the requirements," in a meeting with several managers, the subject of which was the memory leak.
Re:fs.promises.readFile is 40% slower than fs.readFile by josephg on Wednesday March 03, 2021 @09:43PM (#26337981)
I don't know whether its true but there's an old story of engineers a few decades ago working on the guidance system for a missile.

The programmers didn't bother to free() any of their memory - instead they just calculated the maximum amount of RAM their program could consume while the rocket was in the air, doubled it, then installed that much ram in the rockets.

Re:fs.promises.readFile is 40% slower than fs.readFile by fomine3 on Wednesday March 03, 2021 @09:47PM (#26338002)
Re:fs.promises.readFile is 40% slower than fs.readFile by boring_twenties on Wednesday March 03, 2021 @09:57PM (#26338078)
> the ultimate in garbage collection is performed without programmer intervention.

The author owes me a new keyboard.

Re:fs.promises.readFile is 40% slower than fs.readFile by hjek on Thursday March 04, 2021 @05:21AM (#26340731)
Thanks for the link.

Am I the only one who is terrified by reading an "amusing story" about "on-board software for a missile"? The amusement sort of requires us to completely ignore the individuals being blown to pieces.

Re:fs.promises.readFile is 40% slower than fs.readFile by tomgp on Thursday March 04, 2021 @05:42AM (#26340858)
I mean writing software for missiles kind of requires that mind set anyway
Re:fs.promises.readFile is 40% slower than fs.readFile by coldtea on Thursday March 04, 2021 @02:52AM (#26339831)
That's normal, as the rockets don't run an OS, run a specific , very explicitly defined, embedded program, with known states.

It's not going to malloc randomly...

In fact, it's common in real time applications to pre-allocate everything you need at the start of the program or use static memory, and never allocate afterwards.

Re:fs.promises.readFile is 40% slower than fs.readFile by capableweb on Thursday March 04, 2021 @05:09AM (#26340660)
I think the ultimate fact here is that you have a specific runtime period. Once the missile has reached its destination, you have zero memory and the runtime disappears together with the missile.
Re:fs.promises.readFile is 40% slower than fs.readFile by junon on Thursday March 04, 2021 @08:20AM (#26341956)
The ultimate free().
Re:fs.promises.readFile is 40% slower than fs.readFile by panda88888 on Friday March 05, 2021 @01:27AM (#26353508)
A literal destructor.
Re:fs.promises.readFile is 40% slower than fs.readFile by junon on Friday March 05, 2021 @04:00AM (#26354588)
Ooh that's better.
Re:fs.promises.readFile is 40% slower than fs.readFile by boring_twenties on Wednesday March 03, 2021 @09:55PM (#26338054)
Sounds funny, but is it actually unreasonable?

Presumably, the RAM was a rounding error in the total budget.

And this move eliminated an entire class of bugs (use after free).

edit: And, you don't have to worry about memory fragmentation, or how long free() might take in the worst case.

Re:fs.promises.readFile is 40% slower than fs.readFile by gizmo686 on Wednesday March 03, 2021 @10:21PM (#26338221)
When the European space agency designed the Ariane 4 rocket allocated 16 bits to some variable relating to its horizontal velocity. This variable was only used during the first minute of flight, and engineers computed that it could not possibly overflow given the launch profile Ariane 4 used. Because of this and limited processing power, engineers omitted an overflow check. This worked fine, and Ariane 4 would go on to launch succesfully 113/116 times (97%).

In 1996, Ariane 4's successor, Ariane 5, took its maiden voyage to carry the Cluster constellation into orbit, when this happened https://www.youtube.com/watch?v=gp_D8r-2hwk&t=54s

Ariane 5 used a different launch profile. The impossible was now possible and the 16 bit value overflowed. The inertial reference system failed, along with its backup (which was running the same code), causing the rocket to receive wrong data.

Re:fs.promises.readFile is 40% slower than fs.readFile by stonogo on Wednesday March 03, 2021 @10:26PM (#26338250)
Sounds like more of a warning against blindly copy-pasting code across projects than anything against the Ariane 4 design.
Re:fs.promises.readFile is 40% slower than fs.readFile by cutemonster on Thursday March 04, 2021 @12:50PM (#26345541)
Yes I agree.

At the same time, having added big uppercase warnings in the Ariane 4 source code and architecture docs, might have prevented this.

So, important, in safety critical code, to assume that others might blindly copy paste in bad ways -- and then try to warn them, although you might not be there any longer

Re:fs.promises.readFile is 40% slower than fs.readFile by Karunamon on Thursday March 04, 2021 @01:13AM (#26339224)
This sounds distressingly similar to the Therac-25 failures. A radiotherapy machine who's software was (blindly?) copy-pasted from a previous version of the system which had hardware interlocks to prevent unsafe configurations of the radiation emitter.

The new one did not have these interlocks, instead doing everything in software. The result of this was a few people being fatally irradiated when a certain race condition was triggered.

Re:fs.promises.readFile is 40% slower than fs.readFile by a_imho on Thursday March 04, 2021 @05:29AM (#26340780)
I know the relevant xkcd, but it is always Ariane, Therac and Mars Climate Orbiter.
Re:fs.promises.readFile is 40% slower than fs.readFile by zucker42 on Wednesday March 03, 2021 @10:21PM (#26338218)
I guess the problem is if their calculations are wrong and they are actually allocating more memory than expected.

I think a better approach (and one which NASA uses from what I've read) is to only use static memory.

Re:fs.promises.readFile is 40% slower than fs.readFile by kdtsh on Wednesday March 03, 2021 @09:59PM (#26338092)
Not at all unreasonable. You could very rightly consider any other arrangement ‘overengineered’
Re:fs.promises.readFile is 40% slower than fs.readFile by eternalban on Wednesday March 03, 2021 @10:09PM (#26338151)
Eminently reasonable: dispensing with memory management (allocate/gc) for an embedded real-time missile guidance system. It may have even had static memory layout which likely further improves performance.
Re:fs.promises.readFile is 40% slower than fs.readFile by willbudd on Wednesday March 03, 2021 @10:18PM (#26338204)
I'd be inclined not to use the heap at all though in that case. Just preallocate static arrays in each location.
Re:fs.promises.readFile is 40% slower than fs.readFile by brmgb on Thursday March 04, 2021 @01:23PM (#26346094)
More common than you think and a good way to do it. In a hard-real time environment where you need strong guaranties provably overshooting is a sane strategy. Freeing is not free. Missiles are extreme because they never will be reused but you can do the same at the process level. You just give the process more than it will need during its lifetime and don't bother with memory management.
Re:fs.promises.readFile is 40% slower than fs.readFile by fireattack on Wednesday March 03, 2021 @08:51PM (#26337603)
It doesn't disturb me unless he/she is a core dev of node.js. I mean, anyone can say anything they want. Not to mention it's likely a joke.
Re:fs.promises.readFile is 40% slower than fs.readFile by docmars on Wednesday March 03, 2021 @10:08PM (#26338141)
I agree -- and I'd venture to say that the sentiment could be alluding to the fact that mistakes and things overlooked in software development are inevitable.

Don't take this for defending him, but it's in the realm of possibilities ¯\_(ツ)_/¯

Re:fs.promises.readFile is 40% slower than fs.readFile by CyberRabbi on Wednesday March 03, 2021 @05:53PM (#26335986)
Well his point is this technically isn’t a bug because comparable performance to fs.readFile was never guaranteed as part of the API contract. I don’t think his statement implies we generally ought not to expect excellence nor that effort shouldn’t be spent on improving things.

I think his point is valid even if slightly tongue in cheek. Bugs are defined by the contract / specification not wishful thinking.

Re:fs.promises.readFile is 40% slower than fs.readFile by hmillison on Wednesday March 03, 2021 @08:51PM (#26337602)
As engineers, we should be capable of critical thinking beyond this. Otherwise you will end up with barely working enterprise software like the sibling comment mentioned.

If this is how you do your work, you are asking for a computer to replace you! We should aspire to be better than this. It’s crazy to me that people take massive salaries and expect other people to spoon feed their tasks to them.

Re:fs.promises.readFile is 40% slower than fs.readFile by carlmr on Wednesday March 03, 2021 @09:38PM (#26337938)
>It’s crazy to me that people take massive salaries and expect other people to spoon feed their tasks to them.

I remember being one of two software engineers working on a project in a small company. We were cooperating with two bigger companies delivering other parts of the system.

I kept asking myself: "These guys have hundreds of well paid engineers working on this, and they never deliver! Are they sabotaging the project?".

In the end we delivered the finished prototype and the customer ran a 48h acceptance test, their parts fizzled out almost immediately, while ours just kept running.

It took me a few years and joining a bigger company to notice that thinking about what you're doing is not expected in bigger corporations, where everything is bureaucratized. Also if the company is big enough it can shift the deadlines set by its customers. It drove me near madness whenever a colleague said something "wasn't their job". I never heard such an attitude before, and these people were paid twice as much as in my previous company.

I still, to this day, hope that a lot of these people get replaced by computers. Defective programs can at least be improved.

Re:fs.promises.readFile is 40% slower than fs.readFile by hmillison on Wednesday March 03, 2021 @09:59PM (#26338101)
Agree with this sentiment. I had a short stint at a large tech company and the sort of attitude you describe is what turned me off from working there longer.

“Not my job” people tend to be the most frustrating folks to work with. While I understand wanting to mainly do the work you were hired for, there are always going to be times where you have to roll up your sleeves and do something different.

I wish I was the kind of person who would thrive in that environment because it sounds nice, but I’m not wired that way.

Re:fs.promises.readFile is 40% slower than fs.readFile by cbm-vic-20 on Wednesday March 03, 2021 @11:06PM (#26338472)
I'm a large tech company employee, and I use "Not my job" sometimes because it means that I believe that the issue could be handled more effectively by someone else, or that I should not be the one to address the issue for political reasons. So it's less of a "not my job" and leave it at that, but more like "not my job, but Jane over on that other team is closer to that code and has a better understanding of what's going on."
Re:fs.promises.readFile is 40% slower than fs.readFile by carlmr on Thursday March 04, 2021 @03:18AM (#26339995)
I was speaking more of different departments giving the run around pointing to each other in a circle and saying "not my job". The problem I see here as that there are many things that need to be done and rarely is the coverage of "job descriptions" 100%.
Re:fs.promises.readFile is 40% slower than fs.readFile by mgkimsal on Thursday March 04, 2021 @07:01AM (#26341331)
Rant: I've worked with a few where a simple "not my job" is actually an improvement. I've had "not my job, you figure it out" when asking for assistance from others, which is weirdly worse.

"When I pass X in, I'm not getting anything back - no error, I can't see the logs. Can you assist?"

"Not my job - you figure it out. We can't be expected to know how everything works."

"Yes but... this is literally something your team wrote in the last 3 weeks to support the larger project we're all on, and I was told to make my code work with yours. Have you ever tested taking input? If so, what am I supposed to pass in to your system?"

"Not my job - we're not here to babysit you - go read the code."

Later... someone else...

"Why are you spending all the time trying to trace through this code? You just have to ask. You have to learn to talk to people."

I sent over screenshots of the previous 'conversation' and got nothing back.

Thankfully this doesn't happen very often, but I'd realized that this org had segmented some teams so poorly, and put such deadlines on, that the culture of half the teams was "do minimal work and throw it over to someone else". It was more confusing because I interacted between a few internal teams, and some teams literally did not believe other people behaved this way. Even with written evidence, the problem was always assumed to be "oh, you're just not asking the correct way".

Re:fs.promises.readFile is 40% slower than fs.readFile by austincheney on Thursday March 04, 2021 @05:32AM (#26340799)
It seems to be magnified on the front end. The name of the game is “easier”, everything else be damned. Try take someone’s pet framework away (or jQuery).
Re:fs.promises.readFile is 40% slower than fs.readFile by CyberRabbi on Thursday March 04, 2021 @02:40AM (#26339760)
> It’s crazy to me that people take massive salaries and expect other people to spoon feed their tasks to them.

I’m not sure where in my comment you got the idea that I was advocating for engineers to have their tasks spoon fed to them by other people. My comment is simply about reading comprehension and not arguing against strawmen.

Re:fs.promises.readFile is 40% slower than fs.readFile by mr_toad on Wednesday March 03, 2021 @06:27PM (#26336335)
This is how enterprise software is written. Performs exactly as specified, and completely unusable.
Re:fs.promises.readFile is 40% slower than fs.readFile by CyberRabbi on Thursday March 04, 2021 @02:45AM (#26339787)
It’s also how great software is written. Assuming a subcomponent behaves in a way that it does not claim to isn’t a recipe for functional software, enterprise or otherwise.
Re:fs.promises.readFile is 40% slower than fs.readFile by xiphias2 on Wednesday March 03, 2021 @06:14PM (#26336199)
It wasn't categorized as a bug, but as a speed issue.

Do you categorize thinking that JSON parsing takes at most O(n log n) time as wishful thinking as well?

It's humanly impossible to code for contract, that's why generally it's important to strive for no surprises in an API. This is the only way to build more and more complex software over time.

Re:fs.promises.readFile is 40% slower than fs.readFile by arghwhat on Wednesday March 03, 2021 @05:35PM (#26335773)
I fear that the individual might even be serious...
Re:fs.promises.readFile is 40% slower than fs.readFile by ncallaway on Wednesday March 03, 2021 @05:36PM (#26335790)
It seemed pretty clear that it's a joke to me, with the thinky-face emoji after it, but that's just my reading of it.
Re:fs.promises.readFile is 40% slower than fs.readFile by arghwhat on Thursday March 04, 2021 @03:08AM (#26339932)
Last I checked that wasn't an indicator for sarcasm, but maybe GitHub emoji culture has just gotten away from me.
Re:fs.promises.readFile is 40% slower than fs.readFile by bryanrasmussen on Thursday March 04, 2021 @04:41AM (#26340466)
I don't know, I might say it as a joke, therefore seeing it said I assume they say it in the same manner as I would with the sound of innocent wonder that can be used to denote sarcasm.

I think as a general rule it is good to assume the best, even though I myself might not always be able to do so because of various limitations of understanding.

Re:fs.promises.readFile is 40% slower than fs.readFile by lucideer on Thursday March 04, 2021 @09:47AM (#26343076)
Sarcasm in text can be hard to discern, but that looks like sarcasm to me.

Then again, 206 downvoters didn't seem to think so (unless their reason for downvoting was objection to such a low form of wit).

Re:fs.promises.readFile is 40% slower than fs.readFile by cutemonster on Thursday March 04, 2021 @12:54PM (#26345618)
Sarcasm -- yes maybe, especially with the thoughtful smiley

Now when I think about it

> such a low form of wit

I think it's fun :-)

Re:fs.promises.readFile is 40% slower than fs.readFile by artursapek on Thursday March 04, 2021 @12:01AM (#26338833)
Excellence? This is NodeJs we’re talking about.