Why did early Windows need to defragment & Why don’t Linux and macOS need defragmentation

Why does Windows need to defragment?

  • FAT file systems, whose design determines that the same file may be scattered in different places on the disk
  • Solid-state drives (SSDS) were not popular in ancient times, and the random read/write performance of mechanical hard drives (a lot of time spent seeking and spinning) was poor

Why don’t Linux and MacOS need defragmentation?

  • The design of file system based on block allocation makes the probability of fragmentation on disk very low, delayed allocation, automatic defragmentation strategy liberates the users of operating system, in most cases does not need to consider disk fragmentation;
  • The random read/write performance of SOLID-state disks is much better than that of mechanical disks. Although random read/write performance is different from sequential read/write performance, the difference is not as great as that of mechanical disks. Frequent defragmentation can also affect SSD service life;

Why is IPv6 so hard to replace IPv4

First, IPv6 addresses the problem of running out of IP addresses. The reason why there is no substitution can be divided into two aspects:

  1. IPv4 address exhaustion is alleviated:
    1. NAT alleviates the shortage of IPv4 addresses: Lans expose the same IP address but different ports. NAT can protect private internal networks and function as a firewall
    2. IPv4 address management: More fine-grained management and control (classless inter-domain routing (CIDR) based on variable-length subnet masks) IPv4 addresses and recycling idle resources.
  2. IPv6 design problems
    1. Backward compatibility: Protocol transition can only be achieved through dual stack, tunneling, or NAT64

Why can’t MD5 be used to store passwords

Even hash functions are not secure enough to store passwords.

  • Hashing: An attacker can crack a rainbow table (a large table of predicted hashes containing common passwords)
  • Hash with salt: hash function calculation faster; Hash collisions are easy to crack in the case of a better GPU

Other password storage methods:

  • Encryption: The flaw is “how to store the secret key used to encrypt the password”
  • Bcrypt: Bcrypt is also a hash, but it is slow to compute large numbers of passwords, greatly increasing the cost of attacks.

The above four posts are from a blogger’s “Why design this way” series, with some interesting questions that are worth checking out

JavaScript Debugger principle revealed

  • The essence of a computer is an interpreter
  • The Debugger implementation
    • Compiled languages/executables: CPU supported mid-tier mechanism. softirqsThe debugger program will change the instruction content to INT 3 (0xCC, 3 interrupt) at the point where the breakpoint needs to be set; 
 Record the replacement machine code and replace it if necessary. Hardware interrupt: 4 interrupt registers provided by CPU (DR0-DR3)
    • The V8 engine exposes the ability to set breakpoints, obtain environment information, and execute scripts through the socket. The socket transmits information in the format of V8 Debug Protocol
  • Nodejs debugger:
    • – inspect
    • – inspect – BRKFirst line breakpoint
  • Debugger Adaptor Protocol

Product thinking for front end engineers

The front end also needs to learn some product thinking and ask questions in requirements meetings.