TLDR:
systemctl --user --now disable pipewire-media-session.service
pulseaudio --start -vvv
REF:
Khác với window's UAC, trao quyền cho user, AppArmor giới hạn khả năng truy cập cho các program
AppArmor
Chạy dưới kernel
Quản lý program theo Profile. có 2 mode với Profile
Ngoài các cái chạy mặc định lúc khởi động, có những cái bị disable (trong /etc/apparmor.d/disable
). VD với firefox:
sudo aa-enforce /etc/apparmor.d/usr.bin.firefox
sudo ln -s /etc/apparmor.d/usr.bin.firefox /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.bin.firefox
Install AppArmor utils
apt-get install apparmor-utils
Tạo Profile:
aa-genprof /path/to/application
sudo aa-logprof /path/to/application
sysstemctl stop apparmor
sysstemctl restart apparmor
AppArmor giới hạn quyền truy cập của program vào các file. Cung cấp công cụ kiểm tra các file ứng dụng truy cập, log vi phạm.
Nếu có lỗi về quyền thì nên check cái này.
Error in Xshell "no matching key exchange algorithm found"
Add these lines to the end of /etc/ssh/sshd_config
, then restart process:
Ciphers [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
MACs [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,[email protected]
The latency is the tiem spent waiting before an operation is performed.
Performance issues can be quantified using latency and then ranked because they are expressed using the same units (times). Từ đó đánh giá xem việc tối ưu có ok không, bằng cách xem xét latency tăng lên hay giảm xuống. Việc đánh giá này khó mà làm đc với các thông số khác, vd như IOPS metrics.
Khi có thể, hay convert các metric types khác về latency để cho phép so sánh. Ví dụ: nếu phải chọn giữa 100 network I/O hay 50 disk I/O, ta nên chọn cái nào? Nhưng nếu so sánh giữa 100ms network I/O và 50ms disk I/O, sự khác biệt là rõ.
Vì thời gian đo đc, so sánh đc, nó giúp ta cảm nhận đc thời gian (dịch hơi ngu từ "to have an instinct about time"), và có kì vọng phù hợp cho latency cho các jobs khác nhau của hệ thống
Ta cần biết một vài trade-offs phổ biến (các tập tiêu chí mà ta chỉ chọn đc 2/3):
Có những tiêu chí mà khi sửa, ta sẽ được cái này mà mất cái kia, khó mà vẹn cả đôi đường. Một vài ví dụ:
Việc tuning hiệu quả nhất khi được thực hiện càng gần chỗ "the work is performed". Nghĩa là sao, lấy một vài ví dụ cho dễ hiểu:
Layer | Example Tuning Targets |
---|---|
Application | Application logic, request queue sizes, database queries performed |
Database | Database table layout, indexes, buffering |
System | calls Memory-mapped or read/write, sync or async I/O flags |
File | system Record size, cache size, file system tunables, journaling |
Storage | RAID level, number and type of disks, storage tunables |
Vì hệ thống thường là để cho application chạy trên đó, tập trung phần này thường mang lại big wins. Ngoài việc tối ưu db query, queue, thì việc phát triển nhanh chỉ chú ý tới sự chính xác, khi nào có problem performance thì mới quay qua fix.
Một chú ý nhỏ, việc quan sát ở OS-level cũng giúp nhìn ra vấn đề ở tầng application.
Cài này là sự phù hợp, mỗi tổ chức hay môi trường có một yêu cầu riêng về performance. Tiêu chí cần phải có ở tổ chức này có thể không cần ở tổ chức khác, nó không phải đúng hoặc sai mà phụ thuộc vào ROI (return on investment).
Tuy nhiên, system performance không phải chỉ mỗi liên quan tới cost, nó còn có end-user experience. Nếu trải nghiệm khách hàng tệ quá thì ko hay, nó cũng sẽ ảnh hưởng doanh thu.
Khi thực hiện phân tích performance, cái gọi là level of appropriateness comes in to play in deciding when to stop analysis.
When doing performance analysis, ta cần biết đâu nên là điểm dừng. Có một vài vd:
Khi là performance engineer, đánh giá ưu tiên cho các vấn đề khác nhau để thực hiện là một nhiệm vụ quan trọng
Các tính chất của hệ thống thay đổi theo thời gian (thêm user / phần cứng mới / updated software). Vì vậy các thông số có thể oke tại một thời điểm nhưng có thể trở thành nghẽn tại một thời điểm khác.
Khi thay đổi một thứ gì đó, nên lưu lại để xem xét sau này. Khá là ổn khi lưu lại trên version control system với chú thích rõ ràng. Ngoài ra có thể dùng các configuration management tools (vd Puppet, Salt, Chef ...)
Ứng dụng chạy ngon hay không có thể do architecture hoặc implementation. Hoặc cũng có thể do lượng tải chạy vào hệ thống.
Túm lại, cần phải test tải cho hệ thống, để xem hệ thống hành xử ntn.
Biểu đồ hiệu năng của hệ thống khi tăng dần tải gọi là scalability. Đoạn đầu thì là linear nhưng khi knee point is reached, khả năng xử lý giảm xuống (thoughput)
Điểm knee point này xảy ra khi một thành phần nào đó đạt tới 100% utilization: the saturation point. Thành phần đó đạt 100% utilization và queue của thành phần này bắt đầu xuất hiện thường xuyên và dài hơn.
Có những thành phần mà khi hết utilization sẽ làm hệ thống "chậm" nhanh hơn, vd memory hoặc disk I/O, cũng có những cái mà khi nó hết thì hệ thống "chậm" chậm hơn xíu, vd CPU utilization.
Hệ thống cũng có thể tránh việc chậm đi bằng cách từ chối phục vụ khi hết khả năng xử lý. VD: return 503 Service Unavailable.
Là những thông số được nghiên cứu và thu thập cho việc performance analysis và monitor. Một vài thông số cơ bản:
Metrics are not free, cũng phải dành tài nguyên để thu thập tính toán.
Nên nhớ, metrics đc cung cấp có thể đúng, có thể sai, thường là phức tạp và thiếu tài liệu mô tả, thậm chí có bug.
Time-based Utilization: thời gian mà thiết bị được sử dụng, đc tính theo công thức U=B/T
với U là utilization, B tổng thời gian mà thiết bị đc sử dụng, T là thời gian quan sát.
Thường thì khi đạt 100% utilization thì hiệu năng sẽ giảm đáng kể. Tuy nhiên cũng có những thiết bị mà ko bị degrade như thế vì nó có thể xử lý song song.
Một cách khác hiểu khác cho utilization là ám chỉ capacity thay vì time. Nếu đầy 100% thì coi như không tiếp nhận xử lý đc thêm nữa. Ví dụ cho trường hợp này là memory hoặc storage capacity.
Mức độ mà resource không xử lý thêm được nữa được gọi là saturation. Với capacity based, 100% utilization sẽ là bắt đầu saturation, còn với time-based thì chưa chắc, vì còn tùy thuộc vào khả năng xử lý song song của nó.
Mọi cái saturation là một cái performance issue, là một cái tăng latency, cần phải đc xử lý
Profiling cho ta một góc nhìn tổng quát về hệ thống, cho phép nghiên cứu, phân tích tương quan giữa các thành phần?
Caching được dùng để cải thiện performance. Cache là lưu trữ kết quả từ một tầng storage chậm ở tầng storage nhanh hơn, vd cache disk blocks in RAM.
Nhiều tầng cache có thể đc dùng cùng lúc, vd CPU có nhiều cache layer.
Một thông số cũng khá quan trọng là cache's hit ratio: hit ratio = hits / (hits + misses)
Hit ratio này càng cao càng tốt và sự tăng của 98% lên 99% có ý nghĩa về performance nhiều hơn là từ 10% lên 11%. Tuy nhiên, việc so sánh cache hits rate của hai service chưa chắc là oke, vì có thể service A có hits rate lớn (vd 90%) lại có số lượng miss rate nhiều (200/s)
Cache management algorithms và policies là cách để xác định xem cache lại thông tin ntn.
Các từ trên là để miêu tả trạng thái của cache:
Khi cache mới chạy nó sẽ cần thời gian để warm up. Khi mà cache có kích thước lớn, hoặc storage có tốc độ đọc chậm, thì sẽ cần nhiều thời gian để warm up hơn.
Việc biết cái gì mình biết - biết, biết - không biết, không biết - không biết là khá quan trọng trong SP.
Trong SP có rất nhiều thành phần, việc học thêm, học sâu về system, sẽ giúp ta biến những cái không biết - không biết thành những cái biết - không biết, cuối cùng là biết - biết. Từ đấy giúp giải quyết nhiều vấn đề hơn.
Có thể đọc thêm về cái này: Năm mức dốt & Hành trình truy cầu tri thức
Có hai góc nhìn về SP và sẽ đi kèm với các thông số khác nhau của hệ thống:
Hiểu về OS và kernel là rất cần thiết cho việc phân tích SP. Nhiều lúc ta cần phải phát triển và test các giả thuyết về hành xử của hệ thống, vd như system call được thực hiện như nào, kernel schedule thread trên CPU như nào... Nói chung là cần phải hiểu về OP và kernel.
Mục tiêu của chapter này:
Chương này có 3 phần:
Operating system: là software và files được cài trên hệ thống để nó boot và execute programs. Bao gồm kernel, admin tools, system libraries.
Kernel: là chương trình quản lý hệ thống, bao gồm: hardware devices, memory, CPU scheduling. Nó chạy priviledged CPU mode, đc phép access trực tiếp vào hardware, called kernel mode
Process: OS abstraction and environment for executing a program. Program chạy trong user mode và access to kernel mode (vd thực hiện device I/O) thông qua system calls or trap into the kernel.
Thread: An exceutable context that can be scheduled to run on a CPU. Kernel có nhiều threads và mỗi process chưa một hoặc nhiều thread.
Task: A Linux runable entity, which can refer to a process (with a single thread), a thread from a multithreaded process, or kernel threads.
BPF program: A kernel-mode program running in the BPF execution environment (?????)
Main memory: The physical memory of the system (e.g., RAM).
Virtual memory: An abstraction of main memory that supports multitasking and oversubscription. It is, practically, an infinite resource.
Kernel space: The virtual memory address space for the kernel
User space: The virtual memory address space for processes.
User land: User-level programs and libraries (/usr/bin, /usr/lib)
Context switch: A switch from running one thread or process to another. This is a normal function of the kernel CPU scheduler, and involves switching the set of running CPU registers (the thread context) to a new set.
Mode switch: A switch between kernel and user modes
System call (syscall): A well-defined protocol for user programs to request the kernel to perform privileged operations, including device I/O.
Processor: Not to be confused with process, a processor is a physical chip containing one or more CPU
Trap: A signal sent to the kernel to request a system routine (privileged action). Trap types include system calls, processor exceptions, and interrupts
Hardware interrupt: A signal sent by physical devices to the kernel, usually to request servicing of I/O. An interrupt is a type of trap
Miêu tả chung về OS và kernel
Kernel là core software của OS. What it does depends on the kernel model: Unix-like OS (Linux and BSD) have a monolithic kernel. Nó quả lý CPU scheduling, memory, file systems, network protocols, and system devices (disk, network interfaces, etc)
(Application (System Libraries (System call (Kernel (Hardware))))
System libraries cung cấp interface dễ dàng hơn cho application tương tác với kernel, thay vì phải dùng trực tiếp system call.
Thực ra có thể không cần phải dùng System libraries, ví dụ Golang runtime có syscall layer riêng mà ko cần system library, libc
.
Kernel thường chỉ chạy theo yêu cầu (app call system call), cũng có những tác vụ không phải là system call cần tiêu tốn CPU nhưng không đáng kể. Workload cần thực hiện I/O thường xuyên (vd web server), execute mostly in kernel context. Workload that are compute-intensive run in user mode, uninterrupted by the kernel.
Kernel cũng có thể ảnh hưởng tới performance của compute-intensive workload. Vd: chọn những core có warmer cache thì tốc độ xử lý cao hơn.
Kernel runs in a special CPU mode called kernel mode, full access tới tất cả thiết bị, thực hiện privileged instuctions.
User programs (processes) run in user mode, và request các privileged operations thông qua kernel via system calls, such as I/O.
Vì mode và context switches tốn một chút tài nguyên, một vài cách tối ưu:
Kernel and user mode have their own software execution contexts, including a stack and registers. Some processor architectures use a separate address space for the kernel, which mean the mode switch must also change the virtual memory context.
Như đã biết ở trên, system call để yêu cầu kernel thực thi tác vụ. Có khoảng vài trăm cái system call, được docs hóa ngon lành và ship cùng với OS. System call thường ít thay đổi interface và sử dụng error code để miêu tả lỗi gặp phải.
Một vài syscall quan trọng cần biết:
Nếu không rõ về cái syscall nào thì refer man syscalls
Interrupt là tín hiệu (signal) bắn vào processor để cho nó biết có một cái gì đó xảy ra cần phải được xử lý. Khi nhận interrupt, processor sẽ bắt đầu enter kernel mode, lưu lại trạng thái của thread hiện tại, rồi chạy một cái interrupt service routinne (ISR) để xử lý cái interrupt này.
Có hai loại interrupt:
Như đã nói ở trên hardware devices gửi IRQs (interrupt service requests) đến processor, which arrive asynchronously tới current running software. VD một vài cái hardware interrupts:
Synchronous interrupt đc sinh bởi software instructions. Có 3 loại software interrupt: traps, exceptions, faults; tuy nhiên những khái niệm này lại có thể hoán đổi cho nhau:
Với những cái interrupt này, the responsible software và instructions vẫn nằm trên CPU.
ISRs đc thiết kế để xử lý nhanh nhất có thể, giảm thiểu tác động của việc interrupt tới threads đang chạy. Nếu một interrupt cần phải đc xử lý nhiều hơn, nó có thể được xử lý bằng interrupt thread và scheduled để chạy bởi kernel.
Trong Linux, device drivers chia làm 2 nửa, nửa trên (top half) xử lý interrupt thật nhanh, và scheduling work xuống nửa dưới (bottom half) để xử lý sau. Top half thường chạy ở chế độ interrupt-disable mode để trì hoãn các interrupt khác. Bottom half can either be tasklet or work queues; the latter are threads that can be scheduled by the kernel and can sleep when necessary.
E.g: Linux network drivers. Top half dùng để handle IRQs for inbound packet, which call the bottom half to push the packet up the network stack. The bottom half is implemented as a softirq (software interrupt).
Some code paths in the kernel cannot be interrupted safely. Để tránh những trường hợp này, kernel có thể tạm thời mask interrupt bằng cách set CPU's interrupt mask register. Thời gian interrupt disable time nên nhở nhất có thể.
Một thành phần quan trọng của Linux kernel là clock()
routine, đc chạy bởi timer interrupt. Thường đc chạy mỗi 60, 100, 1000 lần mỗi giây, mỗi excecution của clock gọi là một tick Cái này dùng để update system time, expiring timers và time slices for thread scheduling, maintaining CPU statistics...
Một vài problem với cái clock này (đã đc improved trong những bản kernel hiện tại)
Modern kernels have moved much functionality out of the clock routine to on-demand interrupt, in an effort to create a tickless kernel. Nhằm giảm thiểu overhead và cải thiện power efficiency by allowing processor to remain sleep state longer.
When there is no work to perform, kernel schedules a placeholder thread that wait for work, called the idle thread.
A process is an environment for executing a user-level program. It consists of a memory address space, file descriptors, thread stacks, and registers.
Processes are multitasked by kernel. They are individually identified by their unique process ID (PID).
A process contains one or more threads, which operate in the process address space and share the same file descriptors. A thread is an executable context consisting of a stack, registers, and an instruction pointer (also called a program counter). Multiple threads allow a single process to execute in parallel across multiple CPUs. On Linux, threads and processes are both tasks.
The first process launched by the kernel is called "init" and have PID 1.
Processes are normally created using the fork(2) system call on Unix systems.
The fork(2) or clone(2) syscall may use a copy-on-write (COW) strategy to improve performance. This strategy either defers or eliminates the need to copy memory, reducing memory and CPU usage.
Hình bên dưới show một life cycle of a process.
On-Proc là trạng thái mà process đang đc chạy trên processor. Trạng thái ready-to-run là đã sẵn sàng nhưng mà đang chờ ở queue để đc processor xử lý. Hầu hết I/O will block, đặt process và trạng thái sleep, cho tới khi I/O xong. Zombie state là process đã xong và chờ parent process hoặc kernel remove nó đi.
Process environment bao gồm data trên user address space của process và metadata (context) trên kernel.
Figure 3.9 Process environment
Mỗi kernel context của process gồm: PID, UID, PPID ... Cũng như file descriptors (refer về file mà process đang sử dụng)
Stack là vùng nhớ trên memory dùng cho các dữ liệu tạm thời, tổ chức kiểu LIFO (vào sau ra trước). Nó được dùng để chứa các dữ liệu ít quan trọng ...... Khi một function được gọi, địa chỉ để trả về giá trị được lưu vào stack (the return address is saved to the stack). Một vài registers (thanh ghi) cũng đc lưu vào stack nếu giá trị của nó được dùng ngay sau khi gọi (?)... Tập data trên stack liên quan tới một function được thực thi gọi là stack frame.
Chúng ta có thể xuất ra được các fucntion đã được excute (stack walking). Action này gọi là stack back trace hoặc stack trace. Đây là một công cụ rất hiệu quả trong system performance.
Stack thường đc print theo kiểu leaf-to-root, nghĩa là fucntion mới nhất quay ngược về các fucntion trước nó (hay gọi ra nó).
Vì stack này là các hàm trong source code nên thường sẽ không có document nào ngoài code, trừ một số trường hợp là các hàm là API hoặc được document riêng.
Khi thực thi một system call, process's thread có hai stack: user-level stack và kernel level stack.
Figure 3.10 User and Kernel stacks
...
Virtual memory là một trừu tượng hóa của main memory, cung cấp một góc nhìn riêng biệt, ko chung chạ và gần như không giới hạn cho các tiến trình và kernel. Việc này cũng giúp cho phép mapping nhiều vùng nhớ bên dưới (main memory và secondary storage (disks) nếu cần).
Vì virtual memory cho phép dùng cả hai vùng storage làm mem (cả main memory và disks), kernel sẽ cố gắng giữ những cái tiến trình hay dùng ở main memory cho hiệu quả. Có hai cách kernel dùng:
Process swapping làm hiệu năng tụt, còn Paging thì hiệu quả hơn. Cả hai cách đều dùng thuật toán least recently used. Trong Linux từ swapping thường được dùng để chỉ tới paging.
Unix và derivative của nó thường chia một khoảng thời gian thành nhiều phần nhỏ và phân bố cho các process khác nhau để chạy nhiều process cùng lúc. Việc chia thời gian sử dụng processor cho các process được thực hiện bởi scheduler, key component của OS kernel.
Việc phân bổ CPU time giữa các process còn phải cân nhắc yếu tố priority sao cho important work được thực thi sớm hơn. Scheduler track tất cả các thread trong trạng thái ready-to-run, các thread đặt trọng các queue chia theo priority, gọi là run queues.
Khi có nhiều threads cùng muốn được thực thi, priority cao hơn sẽ đc thực thi trước. Kernel threads có priority cao hơn so với user-level process.
Priority có thể đc edit để cải thiện hiệu năng của workload. Workload đc chia làm hai loại:
Policy thường được sử dụng trong UNIX là xác định các CPU-bound workload và giảm priority tụi này xuống, cho phép I/O-bound chạy trước.
File systems là cách tổ chức dữ liệu dưới dạng file và thư mục. File systems cung cấp file-based interface để truy cập dữ liệu, thường dựa trên chuẩn POSIX. The operating system provides a global file namespace, tổ chức theo kiểu top-down tree topology bắt đầu với root level ("/"). Các file system khác join tree bằng cách mount vào các mount point.
Đa số file systems lưu data dưới disks, một số file systems được gen ra bởi kernel, such as /proc and /dev
Kernel cung cấp nhiều phương pháp để isolate process khỏi file namespace, chroot(8) và trên Linux là mount namespaces (cái này thường dùng cho containers).
Virtual file system là một kernel interface dùng để trừu tượng các loại file system, để cho nhiều loại file system cùng hoạt động song song, vd Sun Microsystem vừa có UFS và NFS (network file system)
VFS interface cho phép thêm mới file system type vào kernel dễ dàng hơn. Và cũng cho phép user program và application truy cập file system dễ dàng hơn.
Với các storage-device-based file system, the path từ user-level software tới storage device gọi là I/O stack.
Hình bên dưới mô tả I/O stack. Có một đường bên trái cho phép thẳng xuống block device, bypassing file system. Path này thi thoảng đc dùng bởi administrative tools và databases.
+---------------------------+
| Application |
+------------------+--------+
|
|
+------------------v--------+
| System Calls |
+----+-------------+--------+
| |
| +--------v--------+
| | VFS |
| +--------+--------+
| |
| +--------v--------+
| | File system |
| +--------+--------+
| |
+----v-------------v--------+
| Block Device Interface |
+------------+--------------+
|
+------------v--------------+
| Volume manager |
+------------+--------------+
|
|
+------------v--------------+
| Host Bus Adapter Driver |
+------------+--------------+
|
+------------v--------------+
| Disk devices |
+---------------------------+
Figure 3.15 Generic I/O stacks
Disk I/O thường có latency cao nên các software stack thường cố gắng để cache lại read and write để tránh latency này.
Cache | Examples |
---|---|
Client cache | Web browser cache |
Application cache | — |
Web server cache | Apache cache |
Database cache | memcached |
Caching server | MySQL buffer cache |
Directory cache | dcache |
File metadata cache | inode cache |
Operating system buffer cache | Buffer cache |
File system primary cache | Page cache, ZFS ARC |
File system secondary cache | ZFS L2ARC |
Device cache | ZFS vdev |
Block cache | Buffer cache |
Disk controller cache | RAID card cache |
Storage array cache | — |
On-disk cache | — |
V.d, buffer cache là một khu vực trên main memory tạm thời store recently used disk block. Disk read được phục vụ ngay từ chỗ cache này thay vì phải gọi xuống disk.
Modern kernel cung cấp một stack các giao thức network, đã đc tích hợp sẵn. Giao thức thường được sử dụng là TCP/IP. User-level program truy cập network bằng endpoint mà kernel cấp, endpoint này gọi là socket.
Device drivers là các kernel software cho việc quản lý device và I/O, thường đc cung cấp bởi device vendors. Some kernel hỗ trợ pluggable device drivers, cho phép loaded or unloaded driver mà ko cần phải restart lại.
Device drivers chia hai loại:
Kernel preemption cho phép thread ở user-level có priority cao hơn kernel và đc thực thi trước. Kernel support preemption gọi là fully preemption, mặc dù có một vài code path vẫn ko thể bị interrupt.
Một cách tiếp cận khác đc hỗ trợ là voluntary kernel preemption, where logical stopping points in the kernel code can check and perform preemption (don't understand this :D).
Linux cung cấp nhiều công cụ để cấu hình tunning access tới các resource. Linux có control groups (cgroups) và nhiều cái khác được phát triển để cung cấp việc xử lý.
Phần này mô tả chi tiết Unix-like kernel implementation và focus vào performance.
Linux được tạo bởi Linus Torvards vào năm 1991 với mục tiêu là một free OS cho Intel personal computers.
Linux kế thừa với nhiều ý tưởng từ các OS trước đó: Unix, BSD, Solaris, Plan 9
suser@desktop:~$ systemd-analyze
Startup finished in 2.531s (kernel) + 23.513s (userspace) = 26.044s
graphical.target reached after 23.503s in userspace
suser@desktop:~$ systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @23.503s
└─multi-user.target @23.503s
└─telegraf.service @6.998s +144ms
└─network.target @2.322s
└─NetworkManager.service @1.856s +466ms
└─dbus.service @1.853s
└─basic.target @1.843s
└─sockets.target @1.842s
└─snapd.socket @1.842s +850us
└─sysinit.target @1.835s
└─snapd.apparmor.service @1.787s +47ms
└─apparmor.service @1.641s +144ms
└─local-fs.target @1.640s
└─run-snapd-ns-snap\x2dstore.mnt.mount @11.531s
└─run-snapd-ns.mount @10.989s
└─local-fs-pre.target @620ms
└─keyboard-setup.service @467ms +153ms
└─systemd-journald.socket @456ms
└─-.mount @452ms
└─system.slice @452ms
└─-.slice @452ms
suser@desktop:~$ systemd-analyze blame
21.111s plymouth-quit-wait.service
3.496s apt-daily-upgrade.service
2.084s docker.service
1.305s snapd.service
BPF stand for Berkerly Packet Filter, ban đầu là để cải thiện hiệu năng của packet capture tools. Năm 2013 được viết lại và trở thành engine đa mục đích, dùng cho networking, Observability, và security.
BPF khá là quan trọng trong SP analysis. Nó cung cấp khả năng lập trình với các event resource của kernel: tracepoints, kprobes, uprobes, và perf_events. Vd: BPF program có thể ghi lại timestamp khi start và end khi I/O để tính I/O duration.
What is the difference between a process, a thread, and a task?
What is a mode switch and a context switch?
What is the difference between paging and process swapping?
What is the difference between I/O-bound and CPU-bound workloads?
Describe the role of the kernel.
Describe the role of system calls.
Describe the role of VFS and its location in the I/O stack
List the reasons why a thread would leave the current CPU.
Describe the advantages of virtual memory and demand paging.
========= | |
Transfer file between Linux machines | |
========= | |
1. Server listen with command | |
nc -l -p 80 -q 30 > file.xxx < /dev/null | |
with: -q: number of seconds that server wait for connection | |
TIP: choose value of "-q" wisely =)) | |
2. Client send file | |
cat file.xx | nc server.ip.address 80 |
Thank thầy 🙇