node工作线程
https://nodejs.org/api/worker_threads.html#worker-threads
1234567891011121314151617181920const { Worker, isMainThread, parentPort } = require('node:worker_threads');if (isMainThread) { const worker = new Worker(__filename); worker.once('message', (message) => { console.log(message); // Prints 'Hello, world!'. }); worker.postMessage('Hello, world!');} else { // When a message from the parent threa ...
动态库符号
nm使用123nm /opt/homebrew/opt/qt/lib/QtSvg.framework/QtSvg -UCg | grep QSvgRenderernm /opt/homebrew/opt/qt/lib/QtSvg.framework/QtSvg -UCgj | grep QSvgRenderernm /opt/homebrew/opt/qt/lib/QtSvg.framework/QtSvg -uCg
-U 已定义符号 导出-u 未定义符号 导入-C C++符号名称解析-g 全局符号nm/llvm-nm 不接受MSVC格式 接受MinGW格式
llvm-objdump/llvm-undname1234dumpbin /exports Qt5Svg.dll > exports.txtundname exports.txt > exports_demangle.txtdumpbin /imports Qt5Svg.dll > imports.txtundname imports.txt > imports_demangle.txt ...
macOS界面相关
macOS UIhttps://www.jianshu.com/p/aa89f9addfb8纯代码创建macOS应用,及仿写[NSApp run]
https://www.jianshu.com/p/42a96c8fa94f为什么手动创建的NSApp没有图标,接收不到键盘响应?
https://blog.csdn.net/bravegogo/article/details/51517482mac 隐藏Dock
https://www.hawu.me/coding/2452NSWindow 无标题栏窗口无法获得焦点与 resize 鼠标指示的解决办法
qtbase https://github.com/qt/qtbase/tree/dev/src/plugins/platforms/cocoaQT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORMqt_mac_transformProccessToForegroundApplication();–> [NSApp setActivationPolicy:NSApplicationActiva ...
性能分析方法
Profile分析方法定时采样 获取Stack Framegperftools CPUPROFILER实现分析不支持Windows 支持目前主流的UNIX
12#define SIGPROF 27 /* profiling time alarm */#define ITIMER_PROF 2
libunwind
1234567891011121314struct sigaction sa;sa.sa_sigaction = prof_handler;sa.sa_flags = SA_RESTART | SA_SIGINFO;sigemptyset(&sa.sa_mask);if (sigaction(SIGPROF, &sa, NULL) != 0) { perror("sigaction"); exit(1);}struct itimerval timer;timer.it_interval.tv_sec = 0;timer.it_interval.tv_usec = 1000;timer.it_v ...
Windows性能分析
VSProf
1stackcollapse-vsprof.pl Report20220830-1902_CallTreeSummary.csv | flamegraph.pl > pretty-graph.svg
调试 -> 性能探测器 -> 检测(Instrumentation)检测应用程序以调查确切的调用数和调用时间
https://www.cnblogs.com/sui84/p/13548045.htmlWindows上的火焰图
https://www.thinbug.com/q/5034194VS2010 Ultimate中的代码覆盖率和性能分析命令行工具
VS2022旧工具貌似无法使用 vsperfreport依赖错误 vsperfcmd使用不正常 只能使用GUI
https://github.com/Donpedro13/etwprof
1etwprof.exe profile --target=14888 --output=%cd%\test.etl -m
DTrace分析性能
DTrace Profile Program12dtrace -l -n profile-*dtrace -x ustackframes=100 -n 'profile-997 /execname == "test"/ { @[ustack()] = count(); }' -o user_stacks.txt -c './test'
gprof2dot123brew install gprof2dotgprof2dot -f dtrace user_stacks.txt | dot -Tpng -o output.pnggprof2dot -f dtrace user_stacks.txt | dot -Tpdf -o output.pdf
FlameGraph12brew install flamegraphstackcollapse.pl user_stacks.txt | flamegraph.pl > pretty-graph.svg
InstrumentsRef: https://h ...
DTrace相关
DTrace Likeawesome-dtrace
Windows/macOS12345sudo dtrace -l | wc -lsudo dtrace -l > dtrace.txtsudo dtrace -ln syscall:::sudo dtrace -ln syscall::: | grep entry | wc -lsudo dtrace -ln syscall::: | grep entry| grep \# | wc -l
macOS kdebughttps://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/trace_codescat /usr/share/misc/trace.codes | grep BSC_557个 多出来的5个0x40e0104 BSC_msync_extended_info0x40e0264 BSC_pread_extended_info0x40e0268 BSC_pwrite ...
网站记录
https://versus.com/cn万物皆可对比https://versus.com/cn/categories
CPU缓存
https://www.jianshu.com/p/610507f53824/
L1/L2 Cache速度差别
L1 cache: 3 cyclesL2 cache: ~14 cyclesL3 cache: ~50 cycles
Main Memory: ~250 cycles
Pentium M:To Where CyclesRegister <= 1L1d ~3L2 ~14Main Memory ~240
https://www.jianshu.com/p/e338b550850f从CPU到大约需要的 CPU 周期大约需要的时间
主存 约60-80纳秒
QPI 总线传输 (between sockets, not drawn)约20ns
L3 cache 40-45 cycles,约15nsL2 cache 约10 cycles,约3nsL1 cache 约3-4 cycles,约1ns
寄存器 1 cycle
后台进程
Unix/Linux如何创建一个后台进程https://blog.csdn.net/ACb0y/article/details/66297741、调用fork函数,创建一个子进程。2、先让父进程自然结束。3、在子进程中调用setpgrp(),把子进程的进程组ID设为子进程的进程ID。4、在子进程中调用setsid(),创建一个新的Session(会话),这样子进程就与当前的控制终端脱离,也接受不到当前终端的(ctrl + c)消息。
macOSRef: man daemon –> posix_spawnhttps://github.com/apple-oss-distributions/Libc/blob/main/gen/FreeBSD/daemon.chttps://github.com/aria2/aria2/blob/master/src/daemon.cchttps://github.com/apache/apr/blob/trunk/threadproc/unix/procsup.chttps://github.com/nghttp2/nghttp2/blo ...