keypath

What? allow referring to properties without actually invoking them.
Why do you need it? If you want to create an adapter for a property.

If keypath is used together with generics and associated type, the adapter can fit various types as well. Making it even more powerful and cleaner code.

See detail in this nice article.

Steps to performance tuning

Notes from Practical Approaches to Great App Performance

  • measure existing performance, set up baseline.
  • re-measure performance, compare, document, share.
  • focus on total impact (vs. just an area that are not used by many users, not used frequently)
  • reproduce -> profile -> modify -> repeat
  • good to have automated performance tests to avoid regressions over time (the thousand performance paper cuts)
  • important to understand user usage pattern, so that target is clear and optimizing on the most valuable areas.
  • break large task into smaller steps and write unit tests for each step. That helps pinpoint issue.
  • integration tests are measured from UX perspective, covering not just the task, but all other areas that work together.
  • always start with integration tests, so that you know what area to start the tuning.
  • use Time Profiler to get performance profile.
  • if not debugging threads related, better not to group the trace by thread. To disable it: Call Tree -> uncheck Separate by Thread.
  • how to remove noise, or focus on the signal
    • focus on one thread at a time. To do that: select only the thread that cost the most in the Track Filter panel
    • focus on one message at a time. To do that: select the suspecious in the Heaviest back trace panel
    • remove recursions. To do that: Call Tree -> check Flatten recursion.
    • drill down (bring up to the top level). To do that: right click on the trace -> Focus on subtree
    • hide all objc related messages in call tree (bubble those “cost of doing business” up to the parent callers). To do that: right click -> Charge 'libobjc.A.dylib' to callers
    • hide all small “contributors”. Say for a 2-sec sample range, filter out only trace that > 20ms, that means only focusing on contributors that cost >1%. To do that: Call trace constraints -> 20 for min.
  • even the slowness happens in system lib, there is possibilities to optimize
    • the data you passed into the system lib to operate
    • how many times you are calling this system method
    • system method is calling back into your code via delegates
  • key-value observer (KVO) (i.e., “update UI whenever model changes”) in a loop could impact performance
  • instant app launch means? 500ms to 600ms (that’s how long it takes the zoom animation from the home screen)
  • do initialization, such as DB init, in the background thread, to improve launch time.
  • as little work as possible in the initializers
  • load data on screen synchronously, off-screen data async.
  • strive for constant time.

Moving a placeholder site from Squarespace to Github Page

I have been owning a domain and an LLC with the same name.

Squarespace was my choice since I was about put in more than just a placeholder. $144/year was not bad considering the time it saves me given the features, designs, and flexibility it provides.

However, it ends up a nice looking one-pager is all I need for now. The yearly renewal is around the corner. I decided to move it to Github Page, which is totally free.

Here are the steps:

  1. Create a Github Page.
    1. Login to Github with your username (e.g., examplegithublogin)
    2. Create a new empty repo, examplegithublogin.github.io
    3. Use SourceTree to check it out to a folder locally
    4. Find a free template (on https://www.free-css.com/ etc.), put in the folder, commit and push.
    5. Go to the site (examplegithublogin.github.io) directly. Double check everything works fine.
  2. Unlink from Squarespace
    1. log in to Squarespace -> settings -> domains, then Unlink
    2. If needed, stop auto-renew on Squarespace.
  3. Setup A record
    1. For example, if your domain is registered with Google domains, log in to Google Domains
    2. Remove the Squarespace “Synthetic records”
    3. Add a “@” record, points to the following 4 IP’s (185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153).
  4. Add the custom domain to Github Page settings
    1. Go back to the examplegithublogin.github.io repo -> settings -> GitHub Pages -> Custom domain -> put yourcustomdomain.com in -> save
  5. Check yourcustomdomain.com and http://www.yourcustomdomain.com (with and without https://)
    1. It works for me immediately, but it could take you more time depends on your DNS propagation.
    2. For me, SSL took about 3 mins to start working. (Github needs to issue a certificate behind the scene.)
  6. Done.