9,802 karma · joined May 23, 2010
1. Allocation and deallocation involve calls to calloc/free, which are rather costly. It's easy to accidentally create and destroy an NSObject on each iteration of a hot loop. Be aware that this comes with a performance hit, and can easily come to dominate the time taken by that loop.
2. Retains and releases are pretty fast, especially on Apple's processors (which are optimized for non-contended atomic operations). However, they are atomic operations – some fancy compare-and-swap thing usually – and so you should try to avoid doing them on every iteration of a hot loop.
3. ObjC method calls are slower than C++ vtable dispatch, which in turn is slower than static function calls. Also, there's no inlining opportunity. There is caching to make method calls faster if you call the same method a lot, and the code for cache lookups is impressively fast, but if you need some code to be Fast, consider using C-style functions in critical parts.
4. When in doubt, use the Instruments profiler to find bottlenecks. It's really good.
And now a small grab-bag of more minor ones:
5. +[NSString stringWithFormat:] is surprisingly slow, or it was when last I checked. Its CoreFoundation counterpart is similarly slow. (It's the same underlying code.)
6. When you load a plist, most of which will be deallocated almost immediately, surrounding this with an @autoreleasepool block often does wonders to reduce heap fragmentation. Same goes for other operations which will tend to produce large memory spikes of objects that will stay allocated pending an autorelease pop.
7. The Accelerate framework defines a number of SIMD data types; e.g. simd_float8 is a vector of 8 single-precision floats. You can do arithmetic on them like a normal numeric data type, and the compiler will automatically emit cross-platform SIMD code. If your needs are fairly basic, this is a remarkably easy way to do SIMD programming. I've managed to get ~8x speedups with it before. (A pity that the docs are so lacking.)
https://www.razibkhan.com/p/you-cant-take-it-with-you-straig...
The actual biological reality is fascinating, and so much more interesting than the distorted version you get from unscientific fabulists.
To restate my actual argument, since you haven't really responded to it: what work would you have very poor people do instead? There are other options, but are those options actually better? And how would you or I know?
It seems a little insulting to presume that you know their lives and their employment options better than they do, and should choose in their stead. But that's exactly what people are doing when they put public pressure on these companies to withdraw unseemly-looking options.
Should they take a 60% pay cut to do back-breaking labor at a construction site? Take a bigger pay cut to wash dishes at a restaurant? Or perhaps they could work long hours subsistence farming; that's a pretty common option in Pakistan, if the numbers I'm seeing are at all accurate. I know people who used to do this, and from what I hear it kind of sucks.
Taking distasteful options away from poor people because they might choose those options is one of my least-favorite forms of moral grandstanding, because it hurts people who already have it rough.
https://en.wikipedia.org/wiki/Economic_liberalisation_in_Ind...
> Second, the companies paying these children are extracting value from their labor greater than what they are paying the child laborers.
This is always the case with employment, assuming that the employer isn't getting ripped off: when two parties make a voluntary trade, they're both getting something they value more than what they're trading away.
--
> In other words, this article, in my analysis, is an opportunity to study and question the system that creates the conditions such that there is a labor market comprising children who are available for exploitation for cheap labor by very rich Western companies.
I don't see anything that needs explaining here. Poverty is the default. For almost all of human history we were dirt poor. For almost all of agricultural history we were in a hungry, unpleasant Malthusian equilibrium.
The real miracle is that things are getting better. And a big part of why things are getting better is because it's possible for richer countries to 'exploit' cheap labor in poorer countries – and help them escape poverty by doing it. It's amusing how companies keep looking for cheap labor in different countries every few years, because the places that used to have the cheapest labor got wealthier because of those opportunities. I realize that not everybody shares my aesthetics, but personally I see this as beautiful, even if the ground-level details are a bit grungy.
Even if the allegations of "traumatizing content" are true and not exaggerated cherry-picking, shouldn't the decisions here be made by the people actually involved? When well-meaning, well-fed people take away their choices (and income), this isn't exactly doing them a favor.
I always wince slightly when I see one of these pronunciation guides for words that I actually know how to pronounce, because for some reason they're never quite right. (I don't know how I'd do better, mind you, and this pronunciation would get the job done.)
(Please, I beg you, argue with the opinions that people actually have instead of something you just made up.)