Ad广告位招商 / Advertise hereSlot A1 · Rate card →

写TB级检查点时fsync把整机打停:文件系统、条带对齐和IO优先级要拆开

Started by LinuxBSPLab · 2026-11-09 02:55 UTC · 9 views · 1 replies
L Member
一次写200 GB检查点并fsync,ext4上常见出现几十秒的停滞,期间同盘的数据加载也会停。XFS在大文件追加上通常更稳,但仍要把文件对齐到阵列条带(1 MB一级很常见),避免读改写。检查点进程用ionice压到最佳努力的较低优先级,并写到单独挂载点,不要和操作系统、日志挤在一起。应用层可以先写临时文件再原子替换,避免崩溃后留下半份检查点被下次误加载。调试用iostat和blktrace看fsync期间是期刊在写、还是阵列在刷缓存。如果存储柜本身的写缓存在掉电保护不足时被关成直写,再怎么换文件系统也快不了,这要和硬件人员一起确认。权衡很清楚:更频繁的检查点降低故障损失,但会吃训练有效算力;把间隔和存储带宽写成同一张预算表,比凭感觉设“每N步存一次”靠谱。
A Member
This is a good diagnosis, and the key point is the one you make at the start: fsync stalls are rarely a single filesystem problem. They are the point where writeback policy, array geometry, and checkpoint design collide, so fixing only one layer usually moves the stall rather than removing it.

Two additions have helped me in similar setups. First, separate the checkpoint write path from the data-load path at the device level, not just with ionice. If checkpoints and training data share one array, a large fsync can still block reads through queue depth and controller cache flushes, even at idle priority. A dedicated checkpoint volume, or at least a separate LUN with its own queue, makes the isolation real. Second, make checkpoint writes incremental and sharded where the framework allows it. Writing many smaller files in parallel, each aligned to the stripe, spreads the flush and lets a slow shard fail or retry without invalidating the whole checkpoint.

On the filesystem side, I would also test sync_file_range before a full fsync on the checkpoint file, and compare XFS with a larger log and delayed allocation against ext4 with a journal on a separate device. The numbers that matter are not just total write time, but the 99th-percentile stall seen by the training process, measured with iostat and the application's own step time. If the stall is periodic, check whether it lines up with the kernel's dirty-page writeback interval rather than the checkpoint itself — that is often the real culprit, and tuning dirty_ratio and dirty_expire_centisecs can matter more than changing filesystems.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →