Tuesday, May 19, 2020

Why NetNewsWire Is Fast

Brent Simmons (tweet):

The parsers are fast — but we also do our best to skip parsing entirely when we can. There are two ways we do that.

We use conditional GET, which gives the server the chance to respond with a 304 Not Modified, and no content, when a feed hasn’t changed since the last time we asked for it.

This is wonderful in theory, but it doesn’t seem to work consistently with my blog. I’ve tested it, and the logs show that a few percent of NetNewsWire users are getting 304-cached content, but the vast majority are not. This may be a WordPress issue.

WP Super Cache:

Supercache doesn’t support 304 header checks in Expert mode but does support it in Simple mode.

I think at one point it worked when I hacked WP Super Cache to cache feeds using mod_rewrite, but currently I’m using the unmodified version in Simple mode.

Back to Simmons:

The same API that marks a single article as read is used to mark 10,000 articles as read. This way the database is updated once, the unread counts are updated once, and we push just one action on the undo stack.

The Cocoa frameworks can provide all sorts of notification and undo functionality almost for free, but to get bulk operations right you need to do it by hand.


Update (2020-05-25): See also: Hacker News.

7 Comments RSS · Twitter

Maybe someone will answer my question?

What is the better option to get rid of trackers, open a web page in Safari with an add and tracker blocker installed or to use an RSS reader like NetNewsWire is?

There's a few points in Cocoa to help with specific bulk operations. Wrapping a series of text changes between NSTextStorage -beginEditing/-endEditing comes to mind for bulk text editing without triggering immediate notifications. NSTextView's -shouldChangeTextInRanges:replacementStrings:/-didChangeText is also a nice pair to create a single undoable event with a bunch of changes.

Are NSBatchUpdateRequest and NSBatchDeleteRequest useful within Core Data MOCs, or are they intended more for data migration? I haven't used CD in years.

When doing things by hand, NSNotificationQueue coalesces multiple notifications into one. You can similarly coalesce multiple messages into one within an event loop by calling NSObject +cancelPreviousPerformRequestsWithTarget:selector:object: at the start and NSObject -performSelector:withObject:afterDelay:0 at the end with matching arguments.

Design anything that gets hit hard around a trigger to record state / suspend notifications and another trigger to generate an undo point / resume notifications.

@zeroID Hard to say. I think trackers are far more prevalent on the Web, and blockers probably don’t get 100% of them. On the other hand, trackers are rare in feeds (at least the feeds I read), but I don’t think NetNewsWire does anything about them.

@Hammer The NSTextStorage stuff is fine, but I don’t think it really applies to bulk operations initiated by the user. The Core Data batch requests are great, but you have to set them up manually (marking multiple articles as read won’t automatically turn into a batch) and they don’t handle undo. I agree, notification coalescing and manual suspension are handy.

@ Michael,

Thank you for reply!
Here is a example. The blog owner is not placing cookies at all, but WordPress have trackers installed by default

Cookies: 0 - Third party requests: 38 requests to 10 unique hosts

As Safari is already blocking third party cookies (and a good blocker is very useful also to block advertisements), I would like to know if RSS readers, in this case NetNewsWire is blocking third-party tracking requests?

Thank you

@ Michael

P.S. Your blog on DREAMHOST-AS has:

Cookies: 0
Third party requests: 0 requests

Thank you for not placing cookies and trackers!

@zeroID As far as I know, NetNewsWire doesn’t block anything.

@zeroID If you wish to block trackers in apps other than a web browser, you can use a personal firewall like Little Snitch, edit your computer's hosts file using a blocklist, or run an adblocking device (like a Pi-hole) on your LAN (and then set your computer's DNS server to the LAN address of that device)

Leave a Comment