News for hackers. Stuff that matters.
Re:Next Generation Out of Band Garbage Collection by IshKebab on Saturday November 02, 2024 @06:43PM (#42029764)
A 10% performance improvement on Python code is laughable. You can get a 5000% performance improvement if you switch to a better language.
Re:Next Generation Out of Band Garbage Collection by ziddoap on Saturday November 02, 2024 @07:10PM (#42029921)
I bet the engineers at Instagram were unaware of pythons performance profile when they chose it, you should let them know that they should just switch to a different language.
Re:Next Generation Out of Band Garbage Collection by byroot on Saturday November 02, 2024 @07:16PM (#42029958)
Meta is just a small startup though, they probably don't have enough resources nor the skills to switch to a better language even after they've heard the gospel.
Re:Next Generation Out of Band Garbage Collection by immibis on Sunday November 03, 2024 @03:38AM (#42031865)
The joke is that Facebook literally did, right?
Re:Next Generation Out of Band Garbage Collection by byroot on Sunday November 03, 2024 @03:49AM (#42031902)
Did what? Rewrite Instagram into another language? Do you have any source on this?

Last time I checked they're working on improving Python performance instead (yes I know they forked it into Cinder, but they're trying to upstream their optimizations [0]). Which is very similar to what we're doing at Shopify.

Of course 100% of Instagram isn't in Python, I'm certain there's lots of supporting services in C++ etc, but AFAIK the Instagram "frontend" is still largely a Python/Django app.

The joke is that if Meta thought that replacing all the Python code they have with something else was worth it, they'd have done it already.

[0] https://github.com/facebookincubator/cinder

Re:Next Generation Out of Band Garbage Collection by lucianbr on Sunday November 03, 2024 @04:48AM (#42032133)
> The joke is that if Meta thought that replacing all the Python code they have with something else was worth it, they'd have done it already.

"Worth it" depends on both how much performance improvement you get, and how hard it is to replace. Did you consider maybe the rewriting effort is so humongous that it is not worth doing despite large performance improvements? Thus making the joke not funny at all...

Re:Next Generation Out of Band Garbage Collection by byroot on Sunday November 03, 2024 @05:14AM (#42032209)
That's exactly the joke though. Every time Ruby (or Python) is discussed on HN we get the same old tired question of "why don't they just rewrite in Rust".

But that's some silly engineer tunnel vision, squeezing the very last bit of performance out of a system isn't a goal in itself. You just need it to be efficient enough that it cost you significantly less to run that the amount of revenue it brings you.

I can bet you that moving off Python must have been pitched dozens and dozens of time by Meta engineers, but deemed not worth it, because execution speed isn't the only important characteristic.

So yes, I find it hilarious when HN commenters suggests companies should rewrite all their software into whatever is seen as the most performant one.

Re:Next Generation Out of Band Garbage Collection by IshKebab on Sunday November 03, 2024 @07:44AM (#42032737)
It's usually dismissed because companies think short term, and switching languages is a project with huge short term disadvantages and huge long term advantages.
Re:Next Generation Out of Band Garbage Collection by HumanOstrich on Sunday November 03, 2024 @02:14PM (#42035354)
It's usually dismissed because it's almost always a huge strategic blunder.
Re:Next Generation Out of Band Garbage Collection by debugnik on Sunday November 03, 2024 @04:48AM (#42032134)
I think they meant Facebook switched their PHP code to Hack and HHVM, their own PHP-like language and implementation.
Re:Next Generation Out of Band Garbage Collection by IshKebab on Sunday November 03, 2024 @04:24AM (#42032015)
I don't know if you're joking or not but that is exactly true. Meta went as far as creating their own PHP engine and then a new PHO compatible language because they didn't have the resources to switch from PHP.

Instagram is presumably in the same position. Switching language is basically impossible once you have a certain amount of code. I'm sure they were aware of the performance issues with Python but they probably said "we'll worry about it later" when they were a small startup and now it's too late.

Re:Next Generation Out of Band Garbage Collection by eru on Sunday November 03, 2024 @05:42AM (#42032312)
Well, Facebook also created their own hacked up version of PHP (called Hack) that's presumably easier to migrate PHP to.

Hack is actually surprisingly pleasant, basically about the best language they could have made starting from PHP. (I know, that's damning with faint praise. But I actually mean this unironically. It has TypeScript vibes.)

Re:Next Generation Out of Band Garbage Collection by krapp on Sunday November 03, 2024 @05:51AM (#42032348)
I was excited about Hack when it came out. Unfortunately PHP took just enough from it to kill it. I gave up on it once Composer stopped supporting it, after backwards compatibility with PHP no longer became a goal.

IMHO Hack's best feature was native support for XHP... which (also unfortunately) isn't something PHP decided to take.

Re:Next Generation Out of Band Garbage Collection by eru on Sunday November 03, 2024 @05:56AM (#42032356)
I only used Hack when I was very briefly working for Facebook. (And I used PHP once before nearly 20 years ago by now for some web site I had 'inherited', back when PHP was truly an awful language)
Re:Next Generation Out of Band Garbage Collection by Twirrim on Sunday November 03, 2024 @01:24PM (#42034943)
Hack really gave PHP/Zend the kick up the arse that it seemed to need.
Re:Next Generation Out of Band Garbage Collection by eru on Monday November 04, 2024 @12:46AM (#42038869)
I guess like Scala (et al) and Java? C++ also seems to be learning things from Rust these days.
Re:Next Generation Out of Band Garbage Collection by IshKebab on Sunday November 03, 2024 @07:11AM (#42032614)
Yes I mentioned that.
Re:Next Generation Out of Band Garbage Collection by electricwire on Saturday November 02, 2024 @07:22PM (#42029979)
They may well have been initially, its a pretty puzzling choice
Re:Next Generation Out of Band Garbage Collection by worik on Sunday November 03, 2024 @01:33AM (#42031339)
> I bet the engineers at Instagram were unaware of pythons performance profile when they chose it,

Is the Instagram stack Python? I doubt it, but stranger things have happened

I suspect it is actually some derivative of Apache, or Nginx. Something sensible

Re:Next Generation Out of Band Garbage Collection by httgp on Sunday November 03, 2024 @02:42AM (#42031699)
Instagram is built with Django.
Re:Next Generation Out of Band Garbage Collection by orf on Monday November 04, 2024 @03:24AM (#42039620)
You expect that the instagram stack is something sensible, such as only a web server? What?
Re:Next Generation Out of Band Garbage Collection by rty32 on Saturday November 02, 2024 @08:18PM (#42030240)
Very naive take.

1. 10% performance improvement at Instagram could lead to many millions of revenue "instantly". It is not laughable at any company. 2. It won't be a 5000% performance improvement. Facebook uses its own fork of Python that is heavily optimized. Probably still far from C++, but you should be thinking about languages like Java when talking about performance.

"Better" is a very subjective term when discussing languages, and I hope such discussions can be more productive and meaningful.

Re:Next Generation Out of Band Garbage Collection by foobazgt on Saturday November 02, 2024 @10:17PM (#42030744)
Cinder's benchmarks don't seem "like Java" performance, given they aren't that far off cython.

https://github.com/facebookincubator/cinder/blob/cinder/3.8/...

Re:Next Generation Out of Band Garbage Collection by eru on Sunday November 03, 2024 @05:44AM (#42032316)
CPython itself has seen lots of performance improvements recently. Benchmarks on CPython 3.12 take about half the time they took on CPython 3.9.
Re:Next Generation Out of Band Garbage Collection by IshKebab on Sunday November 03, 2024 @07:15AM (#42032632)
Yeah it's definitely welcome, but even if it is double the performance (doesn't seem to be quite there in my experience) fast languages are still 25-50x faster. It's like walking twice as fast when the alternative is driving.
Re:Next Generation Out of Band Garbage Collection by eru on Monday November 04, 2024 @12:45AM (#42038866)
Yes.

Well, it really depends on whether that alternative is open to you, and at what cost.

So eg lots of machine learning code is held together by duct tape and Python. Most of the heavy lifting is done by Python modules implemented in (faster) non-Python languages.

The parts that remain in Python could potentially be sped up by migrating them, too. But that migration would likely not do too much for the overall performance, but still be pretty expensive to do (in terms of engineering effort).

For organisations in these kinds of situations, it makes a lot of sense to hope for / contribute to a faster Python. Especially if it's a drop-in replacement (like Python 3.12 is for 3.9).

What makes really me hopefully is actually JavaScript: on the face of it, JavaScript is actually about the worst language to have a fast implementation. But thanks to advances in clever compiler and interpreter techniques, JavaScript is one of the decently fast languages these days. Especially if you are willing to work in a restricted subset of the language for substantial parts of your code.

I'm hoping Python can benefit from similar efforts. Especially since they don't need to re-invent the wheel, but can learn from the earlier and ongoing JavaScript efforts.

(I myself made some tiny efforts for CPython performance and correctness. Some of them were even accepted into their repository.)

Re:Next Generation Out of Band Garbage Collection by lucianbr on Sunday November 03, 2024 @04:52AM (#42032141)
> Facebook uses its own fork of Python that is heavily optimized.

So likely the 5000% improvement is no longer possible because they already did multiple 10% improvements? I don't know how this counters the original point.

All clues point to FB going this route because they had too much code already in PHP, and not because the performance improvement would be small.

In any case, "facebook does it" is not a good argument that something is the right thing to do. Might be, might not be. FB isn't above wrong decisions. Else we should buy "real estate" in the metaverse.