“Tesla autonomy day” 记录和想法

Single vendor, move fast, tighter integration, easier regression test, less compatibility bugs. Every year from now, the performance charts will like the ones shown in Apple events. Chip is for self-driving focused, and then software is just for that chip.

特斯拉走的是苹果的路,就是所谓的walled garden。没有好坏。在这个阶段,无疑是可以缩短迭代周期。真心觉得特斯拉能私有化就更加完美,现在花太多精力在跟short sellers打嘴仗了。

这几年媒体报道都集中在model 3的产能和交付上,我以为特斯拉没有花心思在自动驾驶上,比较失望。因为我觉得推动电动汽车方面,特斯拉已经完成了历史使命。如果不去发展自动驾驶,那特斯拉可以从我视线消失了。没想到马斯克这个大嘴巴,能把在自动驾驶方面的突进守口如瓶,也是一个城府很深的人。

All production cars at this moment have the new computer installed.

这又是跟马斯克先狠吹的作风很不符,已经在路上跑了也不说,看来特斯拉完成了华丽转身。当各大厂还在讨论2020年推出第一款长续航电车的时候,特斯拉实际已经离开了那个战场。现在新战场的对手是waymouber。马斯克每次在新战场都很沉得住气的(参考spacexboringneuralink, starlink)。

“Anyone relied on LIDAR is doomed”.

The justification was that human beings drive with vision, not the laser. So autonomy can do the same. My argument would be, humans use vision, drive and kill 3,287 people every day. Don’t think Tesla autonomy affords to kill even 3 people a year. 同时,我也认同LIDAR的必要性不高。LIDAR可以解决很多由于探测精度带来的问题,但我很怀疑在当前特斯拉自动驾驶的诸多挑战里面,那些由探测精度引起的问题排不上前三,甚至排不上前十。与此同时,多个摄像头和硬件加速,可以一定程度代偿探测精度的不足。当简单的结构大量叠加,配合一定的算法,达到足够的冗余容错,可以逼近甚至超过复杂的单个系统。例子很多,简单的几种门电路组成的集成电路,低性能的廉价pc组成的强大的云计算,最近流行的深度学习。

Data collection is about large/various/real

Only annotate the better drivers.

纳闷特斯拉怎么定义better driver,好在哪里?这又从另外一个角度论证了特斯拉一定要卖保险给特斯拉的车主,从统计意义上的数据,理赔少的,基本就是better drivers了。

Robotaxi

Robotaxi是华丽转身,前面提到,我就不多说了。汽车本来就是一个把你从A点带到B点的移动铁箱而已,只是一个世纪的广告洗脑,汽车变成身份象征成功标志。当汽车作为一个容器,回归本质,拥有它的代价会不成比例的高时,可能只有王思聪可以养得起车了。

最后,我想了一下,如果真有私人车辆组成Robotaxi车队的日子,最大的痛点是什么?应该是儿童安全座椅。所以,快速适配特斯拉座位且可以方便折叠收纳的儿童安全座椅,销量会不错。当然了,那之后过不了多久,安全座椅甚至安全带,都会如同当年进电脑机房要穿的白大褂和要换的拖鞋一样,成为承载一段历史的物件。

蓝色起源的Blue Moon发布会

近地行星地表面积实在很有限,移居其他行星解决不了问题。

所以必须要人造太空生态环境和城市。现在之所以发展不起来是因为没有太空建设的基础设施,亚马逊之所以能成功是因为起家的时候已经有物流电脑网络金融都已经是现成的。

蓝色起源使用氢燃料和垂直降落,都不是近地轨道观光需要挑战的,选择它们是因为氢燃料难但最强而且可以分解水来获得,为以后做准备,垂直降落难但容易拓展(越大的火箭越稳定)。

强调近地资源(月球)的可利用性。

使用燃料电池而不要太阳能,是因为月夜长的时候可以持续两周之久。

——

挺高兴看到最耀眼的两个大老板都很投入的发展太空探索,价值观和方法很不相同,但竞争是需要的,相互揶揄免不了。

我觉得不要用现在的科技,去过分假象以后的限制。例如,贝索斯说按照现在的能源需求,几十年之后我们就得吧太阳能铺满整个地球表面,来证明我们一定要找别的地方,而且还要很在意地表面积。先别说以后可能有可控核聚变之类的新能源,就算太阳能也有可能因为材料科学的突破而在单位面积的有效率上飞跃。感觉贝索斯跟马云一样,例如996ICU,道理有时候是这样,但从他们的嘴里说出来,就变得经不起推敲了。

UITableView concurrent issue with UIRefreshControl

The Error 

The exception is thrown in

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

It complains about out of index. For example, indexPath.row is 8, but the data set is empty.

Troubleshooting

The function is called because somehow UI is being updated. But the data set is empty means the data is in the middle of being refreshed. UI shouldn’t be asked to update if data is being refreshed. So need to find out the code causing the UI update.

Root Cause

self.refreshControl.endRefreshing() is called too early in the wrong place of the sequence. Moved it to queryCompletionBlock solve the problem (while refreshing data from iCloud).

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.