24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions
https://www.bitecode.dev/
Email: contact at bitecode.dev
3541.
Python Without the GIL in 2021(docs.google.com ↗)
7 points · by BiteCode_dev · 5y ago · 1 comment
comment 5y ago · link · parent
pip can be configured to use a local warehouse, and there are warehouses that transparently proxy to pypi, but caches any previously fetched result. E.G: https://pypi.org/project/proxypypi/
Since you control it, and it's read only from the outside, you can actually expose it even outside of your network.
But indeed, it must be replicated for npm, cargo, maven, docker...
There is a startup idea here :)
comment 5y ago · link · parent
Is your bandwidth unmeterred?
Do you have redundancy everywhere, including link and power?
Do you have software to remotely manage the server, including install, reinstall and emergency access?
Can I pay you with the company credit card? Do you provide a billing system with VAT?
If the answers are yes, then congrats, you can open your own hosting business.
But remember next year, the servers will be obsolete.
comment 5y ago · link · parent
They were part of PRISM.
They recently added a systematic scan, compare and report routine to all your pictures.
They forces you to tie your phone to an Apple account just to use it. My android phone doesn't have an account, or even an email linked to it.
Apple now has an entire mesh network of BT devices constantly looking up each others, even if some of them are not connected to internet.
The microphone on the Apple device is always on, to answer to hey siri.
Finally, you can't install a real alternative browser on iOS, so no real privacy addons.
They make big claims about privacy nobody can check because everything is closed source. So you have to just trust them.
"But apple doesn't have an ad business"
Oh but they do. And they don't have to play by their own rules in the app store, and have the right to track users, gather device informations, location, etc. Fun thing is, they start the list of information they collect (https://www.apple.com/legal/privacy/data/en/apple-advertisin...) by stating "Apple-delivered advertising helps people discover apps, products, and services while respecting user privacy".
I don't think they are any better, just different. And better at PR.
comment 5y ago · link · parent
Second, it's inefficient. You should leverage humanity experience.
Third, you can learn a lot faster if you start by repeating something without understanding it. Even maths.
So yes, understanding is useful, but doing without understanding is not bad. It's just a tool.
comment 5y ago · link · parent
With secret subpoenas, gag orders and programs like PRISM, they get what they need directly from the source. Either from the services hosting the data, or the devices producing/receiving the data.
The data is never collected while in transit, when it's encrypted. They got the keys for the servers, and back-doors to our devices. They don't care about encryption at all.
Once again, freedom is not a technical problem:
comment 5y ago · link · parent
I imaging debian is also super expensive, and so scaling that must not be easy. Every decision could be thousands of dollars.
comment 5y ago · link · parent
- cheap VPS for hosting, postgres for the db, nginx as a proxy, redis for everything else, including caching.
- deploy python projects by packing them as zipapp with shiv, then use fabric to ssh and performs any migrations necessary. No, not even ansible.
- build, lint, format and test, like all automatizable stuff, are made using pydoit. If you are solo, you don't need a CI service. Your laptop is the CI machine.
Scaling is always the same story:
1 - start with the cheapest VPS possible. This will force you to code with some constraints. Not crazy, just enough to balance it out.
2 - once you start seing your load average rising, just move the db on a second cheap VPS. You just tripled the load you can sustain. Not doubled, tripled. Most solo projects will stop here actually.
3 - wait again, collect some perfs data when you see the site starting to be slow. Check for slow queries, code hot paths, etc. Optimize that, add some cache, setup tasks queues. Use cron to purge / regenerate cache if you need to smooth out the curve. Maybe slap some varnish for extra peps, or just cloudflare.
4 - now you got what looks like a real load, and a more realistic code base, so when you peak again, request more perfs for your server, or migrate to another bigger one. You can scale vertically to crazy highs nowadays. Really, really crazy. You can get terabytes of RAM, 64 cores servers, etc. At your current scale, your service should generate enough money to pay 10 times for it anyway. But you probably won't need to. Even cheap servers are beast, look at the current leaseweb offer: https://www.leaseweb.com/dedicated-servers#NL
For €320.09 per month, you get:
2x 16 cores 2.30GHz
28GB DDR4
4x960GB SSD
30 TB traffic
To put it in context, myspace used to serve all its users with 2 servers only, until they reached 500,000 accounts. Only then it was too much. This was with hardware (and price!) in the years 200x.5 - you will probably never reach this point. This is the point where kubs, load balancers, sharing, etc. start to be interesting.
How to preserve your data:
- Raid
- Dump the db with a _randomized_ cron
- rsync the dump and all assets. You can do it to another server, or just your laptop at the beginning.
You can get fancy with database replication if you want, or use backups that stream in real time.
But there is one trick: not all data are equal. Identify some data in your db that you can't afford to lose, and make sure this one is saved separately and very regularly while being given priority. There are plenty of data, if you have a hole in it, most people don't care. E.G: if 1 tweet out of million from 10 years ago is missing, do you think it affects the service?
Monitoring:
- Sentry
That's all. It's free (or cheap), and for a small service, you don't need real time. It's ok to be down a few hours once a month for most services at first. I have a service with 700k unique users a day, it still goes down sometimes. It's a blip.
Sometimes, log into the servers, run htop and checks what's up. You can install open telemetry later if you really need to, but for now, even HN hug is not going to kill you.
Summary:
- Modern software and hardware are amazing. Max them out. Horizontal scaling is hard, and expensive.
- You don't need a perfect service. Unless you are handling patient cancer data, that is. Don't worry about perfect uptime, 0 data loss, etc. If you are a solo dev, the cost for that is huge. Just do 97% right⋅
- what worked 20 years ago still work today, and will likely be there tomorrow. And you can move from that to the cloud later. The reverse is not that nice.
comment 5y ago · link · parent
And people are still carrying trackers in their pocker. They put cameras in the front door bell, always online microphones with speech analysis in their living room, give all their life records, textual or in images, to giants companies that have demonstrated the ability to store and analyse that forever.
People don't use more free software. They look at you like you are mad if you don't want to install whatsapp. Even in HN we have people still wondering why we should use Firefox.
Why would we be judging Australians as "complacent" ? Humanity is complacent.
I've been told the boiling frog is a myth, but I'm pretty sure frogs are talking about boiling humans as a telling metaphore.
comment 5y ago · link · parent
- limit the size and scope of the unsafe code
- make the unsafe part stand out, "here be dragons", so you know when to be particularly alert
- act as a safe way to encapsulate unsafe code so that it can be used by safe code, and used without the lack of safety propagating outside of the unsafe zone
comment 5y ago · link · parent
While today's use case for assert is unit testing, the actual killer feature of the keyword is that it's removed only from prod.
The idea is that you can write things like function contracts, that are expensive, but only exist in dev.
Now, if one of you dependencies use assert for something they expect to still be in prod, which is the problem we are talking about in the first place, "-o" or "--remove-assertions" will strip their assert too, breaking their code, and hence, yours since it depends on it.
comment 5y ago · link · parent
https://docs.python.org/3/library/multiprocessing.shared_mem...
If you use a data structure that supports the buffer protocol (such as a numpy array), you won't even pay a serialization cost.
Python has made a LOT of progress, concurrency wise. Between asyncio, process pools, threads releasing the GIL and shared memory, you can get much perfs with the stdlib alone.
Then of course you have Dask if you need more later.
comment 5y ago · link · parent
The 2 codes don't do the same thing, if you perform the same computation on the python code (monochrome mandelbrot, inline loop, 49 iterations, etc), you get 0.8 vs 4.8 sec, which seems about right.
I've removed numpy since it's cheating if we compare raw language perfs:
https://0bin.net/paste/nOtLmeMA#0DKGHSvmgoDLPzHlQOhwvVhxxayf...
So yes, Python is about 6 times slower. Significative, but can be worth the compromise if you consider the Python version is much, much easier to read.
And of course, a vectorized algo would be even faster (see pbourke's comment).
What's more, with SharedMemory from 3.8, you could speed that up even in pure Python using multiprocessing by sharing efficiently the array.