Archive for December 5, 2016

Monday, December 5, 2016 [Tweets] [Favorites]

Guarding Against Long Swift Compiles

Soroush Khanlou:

In May, Jordan Rose added a Swift flag for emitting warnings whenever a function takes longer than some threshold to compile. You can leave this flag enabled in your project, and it will warn you whenever any slow functions are added to the project.


Add two flags: -Xfrontend and -warn-long-function-bodies=100, where 100 is the number of milliseconds you’d like the warning threshold to be

Previously: Exponential Time Complexity in the Swift Type Checker.

Update (2016-12-06): Simone Manganelli:

Haven’t seen anyone warn about this, but merely enabling these debugging flags can cause compile time to drastically increase.

The Operating System Fountain of Youth

Jean-Louis Gassée:

Today, macOS is a fully-grown computer operating system, pleasant, fast, flexible. But it’s also enormous — RAM and disk storage requirements are measured in gigabytes — and it isn’t exactly bug-free. An ex-Apple acquaintance recently told me there are something like 10,000 “open” bugs on an on-going basis. The number that are urgent is, of course, a fraction of the gamut, but like any mature operating system, macOS has become a battlefield of patch upon patch upon patch.


It appears that a new direction may have been tempting. At the time that Apple’s smartphone project began, an Apple employee and former Be engineer offered Palm Inc. $800K for a BeOS “code dump” — just the code, no support, no royalties. The engineer was highly respected for his skill in mating software to unfamiliar hardware; BeOS was a small, light operating system; draw your own conclusion… Palm, which had purchased Be a few years before that, turned him down.


iOS managed to succeed where “lite” versions of mature operating systems failed, and it succeeded on a much larger scale than existing personal computers. The ubiquity of iOS devices ensures the operating system’s future, but it’s not just the higher unit volume that’s attractive: iOS is younger and nimbler than its noble and worthy macOS forefather. As I stated last week, it will assume more and more of the duties of Apple’s historic Macintosh.

Exploring Swift Memory Layout

Mike Ash:

This function works on an arbitrary type, takes a value and returns an array of unsigned 8-bit integers, or bytes. After you create an arbitrary item, calling this function and passing it that item and it’ll hand you back the bytes that make it up. This will serve as the foundation for this whole program.


We can’t know how stuff is being treated at this level because we just get a bunch of bytes and we don’t know what they mean. So we’re going to optimistically go through and slice it up into chunks of eight bytes. We take those chunks, pull them all out and ask, “What if these were pointers, what would that mean?”


On Mac and iOS, there is a low level function called mach_vm_read_overwrite. This is a system call where you give it two pointers and how many bytes to copy from one pointer to another. This call works exactly like memcpy from the C standard library except memcpy will crash your program if it is passed a bad pointer, and mach_vm_read_overwrite just returns an error because it is a system call. Since the call is performed at the kernel level, it can be checked safely and return an error saying that the pointer didn’t correspond to a real address. Because we can go through and reliably follow this tree without crashing we can try every pointer by passing it to this function. If it comes back with an error we just ignore it and move on to the next pointer.


dladder gives you the symbol that comes immediately before the pointer you give it. You can choose a starting address and get the symbol information back. If it returns that there is a symbol, advance one byte and test again, and continue testing and advancing until it returns false. This allows you to know exactly how long something is.

Backing Up the Internet Archive

Jason Scott:

The first is that the Internet Archive is adding another complete mirror of the Wayback machine to one of our satellite offices in Canada. Due to the laws of Canada, to be able to do “stuff” in the country, you need to set up a separate company from your US concern. If you look up a lot of major chains and places, you’ll find they all have Canadian corporations. Well, so does the Internet Archive and that separate company is in the process of getting a full backup of the Wayback machine and other related data. It’s 15 petabytes of material, or more. It will cost millions of dollars to set up, and that money is already going out the door.


There are backups of the Internet Archive in other countries already; we’re not that bone stupid. But this would be a full, consistently, constantly maintained full backup in Canada, and one that would be interfaced with other worldwide stores. It’s a preparation for an eventuality that hopefully won’t come to pass.

Via Nick Heer:

If you rely upon the Internet Archive as much as I do, you can give them money to keep preserving websites, live audio recordings, classic PC games, and loads more.

Kim Zetter (via Hacker News):

So after the FBI sent the Internet Archive the NSL in August, demanding the name, address, length of service and a list of all accounts used by one of the archive’s supposed subscribers, the archive and the EFF sent the bureau a letter challenging the legality and constitutionality of the NSL and gag order. They also disclosed in the letter that the archive didn’t possess any records that matched the FBI’s request. Archive subscribers can use their accounts to upload contributions of books, music and other digital material or to comment on material others have uploaded. But the archive had no records of a subscriber matching the FBI’s target.