#3dprinting 6 hashtags

Todd Sundsted
Release v3.6.0 of Ktistec

It is said that there are only two hard things in computer science: cache invalidation and naming things. The story goes: you have something that is expensive to compute, so you compute it once and then you cache it and use the cached value in the future. But the inputs to that computation change, and so the cached value grows stale. You have to decide when and how to recompute that value.

In Ktistec, presenting accurate tag counts is expensive because not every tagged post counts. Posts are deleted, actors are blocked. My own drafts don't count, but when they're published they do. A post tagged with the same hashtag more than once, must count as one. And tag cardinality is not uniform: #3dprinting has hundreds of thousands of posts, others have one or two. Even with indexes, there is no single query that counts all cases in an acceptable amount of time.

So I reached for a cache, counted once and then cached the count. Because I didn't want to maintain adjustments from every place in the code that changed something that touched the count, I settled for eventual consistency and recomputed counts after every server restart.

As it turns out, that's not good enough. On a server with reasonable traffic, an event that affects some tag's count happens every few hours. Days or weeks later there is significant drift. Worse, the implementation didn't recompute on first read, it recomputed on first write (a new tagged object arrives).

This release fixes all that. Counts are still eventually consistent, but all counts are recomputed in a regular background task, so they really are eventually consistent, and care was taken in constructing the query to minimize database (read) locking to ~100-200msec.

Is it better? Yes! Is it perfect? Probably not. Cache invalidation is hard.

Here's the full changelog for this release:

Added

  • Background task to reconcile tag statistics.

Fixed

  • Prevent model hook callbacks from interleaving.
  • Add spacing between content and the sticky footer.

Changed

  • Replace Semantic UI with Fomantic UI.
  • Cache the PURL and GoToSocial JSON-LD contexts.
  • Reduce database lock time when reconciling tags.
  • Block npm dependency install scripts.

Removed

  • The unused idx_relationships_type database index.

In the next release, I'm going to fix a few bugs in the Mastodon-compatible API. These require an internal redesign, so I've held off until a few other things were out of the way. And I'm turning my attention to reading and better tools for surfacing and finding interesting content.

#ktistec #crystallang #activitypub #fediverse

Todd Sundsted

One of the things I've learned to do in my prints, when I have two parts that will be joined together, is create a directional key and matching key holes in each part. The holes should be half the depth of the key. The key and holes should fit together in one direction only. I can't count the number of times I've glued two parts together that were slightly askew, or backwards, or...

CAD drawing of key and parts with key holes
photo of finished parts


#3dprinting

Todd Sundsted

i'm getting some clicking noise from the 3d printer. probably time to read the manual...

#3dprinting

Todd Sundsted

design
print
fiddle
re-print
tweak
re-print
tune
...hours later...
print
finish

#3dprinting

Todd Sundsted

i'm finally running octoprint directly on my prusa mk3s+ via an installed/integrated raspberry pi zero 2 w and octopi. the hardest part was finding and buying the zero 2 w—thankfully they have been showing up in online inventories lately—and the 18mm breakable header. (i also had to hunt down the zero 2 w frame pattern that is a slight remix of the original frame—not linked because there might be some licensing issues in play.)

raspberry pi zero 2 w plugged into the prusa

#3dprinting #raspberrypi #octoprint #octopi #prusa

Todd Sundsted

my favorite 3d printer projects have some utility. i recently installed gridwall panels in my shop but didn't want to put an eye out on one of the hooks, so i designed and printed safety caps for the ends.

safety caps for gridwall hooks

#3dprinting