This section holds the procedure linkage table. See ‘‘Special Sections’’ in Part 1 and ‘‘Procedure Linkage Table’’ in Part 2 for more information.
Function symbols (those with type STT_FUNC) in shared object files have special significance. When another object file references a function from a shared object, the link editor automatically creates a procedure linkage table entry for the referenced symbol.
re* 匹配0个或多个的表达式。 re+ 匹配1个或多个的表达式。 re? 匹配0个或1个由前面的正则表达式定义的片段,非贪婪方式 re{ n} 精确匹配 n 个前面表达式。 例如, o{2} 不能匹配 "Bob" 中的 "o", 但是能匹配 "food" 中的两个 o。 re{ n,} 匹配 n 个前面表达式。 例如, o{2,} 不能匹配"Bob"中的"o", 但能匹配 "foooood"中的所有 o。 "o{1,}" 等价于 "o+"。 "o{0,}" 则等价于 "o*"。 re{ n, m} 匹配 n 到 m 次由前面的正则表达式定义的片段,贪婪方式
match exactlly str
1 2 3 4 5 6 7
# find should use \ to represent the (6|12|3) $ find ~/github/gapbs/ -type f -regex '.*/kron-\(6\|12\|3\).*' /staff/shaojiemike/github/gapbs/kron-12.wsg /staff/shaojiemike/github/gapbs/kron-3.sg /staff/shaojiemike/github/gapbs/kron-3.wsg /staff/shaojiemike/github/gapbs/kron-6.sg /staff/shaojiemike/github/gapbs/kron-6.wsg
re.match与re.search的区别
re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None;
而re.search匹配整个字符串,直到找到一个匹配。
re.match函数
从字符串的起始位置匹配
1
re.match(pattern, string, flags=0)
flags
多个标志可以通过按位 OR(|) 它们来指定。如 re.I | re.M被设置成 I 和 M 标志:
mkdir$HOME/glibc/ && cd$HOME/glibc wget http://ftp.gnu.org/gnu/libc/glibc-2.32.tar.gz tar -xvzf glibc-2.32.tar.gz mkdir build mkdir glibc-2.32-install cd build ~/glibc/glibc-2.32/configure --prefix=$HOME/glibc/glibc-2.32-install make make install
Clang and Clang++ “borrow” the header files from GCC & G++. It looks for the directories these usually live in and picks the latest one. If you’ve installed a later GCC without the corresponding G++, Clang++ gets confused and can’t find header files. In your instance, for example, if you’ve installed gcc 11 or 12.
You can use clang-10 -v -E or clang++-10 -v -E to get details on what versions of header files it’s trying to use.
function climbStairs(n) { if (n === 1) return1; if (n === 2) return2; return climbStairs(n - 1) + climbStairs(n - 2); }
添加与DFS参数相关的记忆化数组,将这个 dfs 改成「无需外部变量」的 dfs。
1 2 3 4 5 6 7 8 9
memo = {} def climbStairs(n): if n == 1:return1 if n == 2: return2 if n in memo: return memo[n] ans = func(n - 1) + func(n-2) memo[n] = ans return ans climbStairs(10)
classModule: def__call__(self, *input, **kwargs): # 在调用 forward 之前执行一些操作 # 例如,调用 forward pre-hooks for hook inself._forward_pre_hooks.values(): result = hook(self, input) if result isnotNone: ifnotisinstance(result, tuple): result = (result,) input = result
# 调用 forward 方法 result = self.forward(*input, **kwargs)
# 在调用 forward 之后执行一些操作 # 例如,调用 forward hooks for hook inself._forward_hooks.values(): hook_result = hook(self, input, result) if hook_result isnotNone: result = hook_result
运行strace -ff -tt -v taskset -a 1 ./timetctxsw2. 应该是不需要strace的,为什么需要记录syscall的信息呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# snode6 2000000 thread context switches in 22987942914ns (11494.0ns/ctxsw)
# snode6 without strace $ sudo taskset -c 1 ./timetctxsw2 2000000 thread context switches in 1073826309ns (536.9ns/ctxsw) $ sudo taskset -a 1 ./timetctxsw2 2000000 thread context switches in 1093753292ns (546.9ns/ctxsw) $ sudo taskset 1 ./timetctxsw2 2000000 thread context switches in 1073456816ns (536.7ns/ctxsw)
# hades 2000000 thread context switches in 20945815905ns (10472.9ns/ctxsw) # icarus 2000000 thread context switches in 19053536242ns (9526.8ns/ctxsw) 2000000 thread context switches in 17573109017ns (8786.6ns/ctxsw) 2000000 thread context switches in 18538271021ns (9269.1ns/ctxsw)
尝试解释不同机器的差异
猜想:
Intel新产品的硬件确实有特殊设计
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
shaojiemike @ snode6 in ~/github/contextswitch on git:master o [19:46:27] $ sudo ./cpubench.sh model name : Intel(R) Xeon(R) CPU E5-2695 v4 @ 2.10GHz 2 physical CPUs, 18 cores/CPU, 2 hardware threads/core = 72 hw threads total
hades1# ./cpubench.sh model name : AMD EPYC 7543 32-Core Processor 1.5 ~ 3.7GHz 2 physical CPUs, 32 cores/CPU, 2 hardware threads/core = 128 hw threads total
# shaojiemike @ icarus0 in ~/github/contextswitch on git:master o [20:41:39] C:1 $ ./cpubench.sh model name : Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz 2 physical CPUs, 32 cores/CPU, 1 hardware threads/core = 64 hw threads total
ubuntu@VM7096-huawei:~/github/contextswitch$ sudo ./cpubench.sh model name : Intel(R) Xeon(R) Silver 4110 CPU @ 2.10GHz 2 physical CPUs, 8 cores/CPU, 2 hardware threads/core = 32 hw threads total