Since the capacity of my brain is limited, I decided to tear down everything, and then piece things together.
Rust Async
Future async/await Pin Send Future Future is something you can poll, trying to make progress, and won’t block if stucked (yield control). And it will call wake_up if progress can be made. pub trait Future { type Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>; } async/await how it works? the executor will repeatedly fetch a Task from the queue, try to make progress on a Future by calling poll if it returned Pending then save it back to the Task when the future can make any progress, the wake will be called, then the Task itself will be pushed to the task queue again, so that the executor will be able to poll it agagin in the near future....
Sophie's World
记一些笔记,有摘录和思考。 前言 伦理学中有黄金律(互惠原则)的概念,世界像一面镜子,你想要别人怎么待你,你就要怎么待人。 伊甸园 只有在思考生命的意义,意识到生命的有限时,才会知道生命的美好。 魔术师的礼帽 在满足了基本的生理需求以后,获得爱与关怀以后,我们需要问自己这样的问题: 我是谁,世界从何而来 探寻这个问题的过程,帮我们建立起对生命的看法,建立(人生观/世界观)? 成为哲学家唯一的要求是,好奇心 不要把一切都视为理所当然,不要习惯一切 要意识到自己的存在,保持好奇心,否则就会沦陷在琐碎的日常生活中,陷入柴米油盐的日常生活 继而沦为无名大众的一分子 神话 人为了解释自然现象,想象出了神话故事 古希腊人开始质疑(赞诺分尼斯), 神话中的神与人太相似了, 人按照自己的形象创造出神 => 开始寻求自然的解释 从神话的思考模式发展到以经验与理性为基础的思考模式 自然派哲学家 关注大自然的循环与变化, 万物如何从无到有 一元论(没有真正的变化) => 多元论(解释循环) 通过理性思考解释所见 德谟克里特斯 原子理论, 大自然由各种形状各异的原子组成,永恒不变,不可被分割 命运 宿命论 <= 对于事件的超自然解释 苏格拉底 xx あいうえお かきくけこ さしすせそ たちつてと なにぬねの はひふへほ まみむめも やゆよ らりるれろ わ
解决DNS污染
由于众所周知的原因,一直以来访问raw.githubusercontent.com, linkedin.com 等网站总是出现无法连接或者跳转到其他地方的问题。 一开始的解决方案是在浏览器里面使用DOH,但是访问国内的网站速度会明显下降。 一顿Google之后,使用了以下解决方案: 使用AdGuardHome和SmartDNS: Client -> dnsmasq:53 (转发/上游?) -> OpenClash:7874 -> AdGuardHome:5553 -> smartdns:6053 [with cache] 这样既可以使用OpenClash的分流,也能使用AGH和SmartDNS的功能。 使用以后明显感觉浏览速度快了不少,也能正常访问linkedin.com了。 目前出现了一个问题, *.cn全部都会解析成127.0.0.1…, 尝试清理本地cache: resolvectl flush-caches 使用了一段时间,还是会间歇性地跳到linkedin.com, 有空试试mosdns, try Domain Address Rules: ~~nameserver /linkedin.com/fq_dns~~ 目前解决方案: DNS: Clent -> dnsmasq:53 -> OpenClash:7874 -> AdGuardHome:5553 [with cache] -> doh-0 -> doh-1 -> doh-2 Clash: redir-host wth rules 虽然是redir-host,但由于AdgHome有Cache,所以效果和fake-ip差不多其实。 就算国内doh的dns返回了污染后的ip,但是这个ip只在mapping的时候被用到,所以无所谓,(只要没有两个域名被分到一个ip上)。
Feeling good!
I’m married, feeling good!
Listen to Me
I’m blind when I open my eyes, I lost myself in the sea. Only when I close my eye, listening to myself, I become myself, and guided ‘me’.
Rust Lifetime
The problem Dangling reference is bad, we don’t want it. How rust compiler helps Rust compiler use borrow checker to validate references, every reference has a lifetime. fn main { let x: i32 = 0; //------------------+--- 'b // | let y: &i32 = &x; //----+--'a | // | | println!("x: {}", y); //----+-------------+ } Every reference must be valid, no dangling reference is possible. Immutable reference must not be changed anywhere in it’s lifetime....
Black Hole
There is a black hole, around me. Eating my attention, my time.
Dynamic Memory Allocation
what is it? An interface that connects the user-code and virtual memory provided by the system. Because a users jut can’t use sbrk system call to require memory, that would be a nightmare. 不同的操作系统,系统调用还不一样,那么还要维护多套代码,显然是不可能的。 metrics throughput fragmentation Fragmentation Internal: < block-size External: there is enough aggregated heap memory, but no single free block is large enough. Hard to assess, depends on future requests tradeoff It’s all about tradeoff, space-time, throughput/fragmentation....
ICS-CMU Notes: Lec 17 Virtual Memory
Why Virtual Memory for security, isolates address spaces use main memory efficiently, as a cache for the disk simplifies memory management DRAM cache organization Because Disk access is 10k slower than DRAM, so the cost of a page fault is far more expensive than choosing a better victim to evict when there is a conflict or a miss. Consequences Large page(block) size Fully associative Any VP can be placed in any PP(physical page) Requires a large mapping function Highly sophisticated than simple LRU, but because it’s in software (kernel code) instead of hardware as we do in L1, L2 cache, it’s relatively acceptable Never write through, too slow Page Table page table is an array of page table entries (PETs) that maps virtual pages to physical pages, it’a a per-process kernel data structure in DRAM...