Repository: pingcap/tidb
File: pkg/lightning/mydump/region.go (Go)

Code before:
		largeFiles             sync.Map
		parallelSplitThreshold = cfg.MaxChunkSize * int64(concurrency)
	)

	for _, info := range meta.DataFiles {
		eg.Go(func() error {
			select {
			case <-egCtx.Done():
				return egCtx.Err()
			default:
			}

			var (
				regions []*TableRegion
				sizes   []float64
				err     error
			)
			if info.FileMeta.Type == SourceTypeParquet {
				regions, sizes, err = makeParquetFileRegion(egCtx, cfg, info)
			} else if info.FileMeta.Type == SourceTypeCSV && cfg.StrictFormat &&
				info.FileMeta.Compression == CompressionNone &&
				info.FileMeta.FileSize > cfg.MaxChunkSize+cfg.MaxChunkSize/largeCSVLowerThresholdRation {
				// If a csv file is overlarge, we need to split it into multiple regions. This can only be done for
				// uncompressed files with strict format. Besides, the check threshold is increased by 1/10 of the
				// `max-region-size` to avoid splitting small chunks, because tools like dumpling may dump files whose
				// size is slightly exceed the `max-region-size`.
				if info.FileMeta.FileSize > parallelSplitThreshold {
					// For extremely large csv files, we split them later.
					largeFiles.Store(info.FileMeta.Path, info)
					return nil
				}
				regions, sizes, err = SplitLargeCSV(ctx, cfg, info, false)
			} else {
				regions, sizes, err = MakeSourceFileRegion(egCtx, cfg, info)
			}
			if err != nil {
				logutil.Logger(egCtx).Error("make source file region error", zap.Error(err), zap.String("file_path", info.FileMeta.Path))
				return err
			}
			result := fileRegionRes{info: info, regions: regions, sizes: sizes, err: err}
			fileRegionsMap.Store(info.FileMeta.Path, result)
			return nil
		})
	}

	if err := eg.Wait(); err != nil {
		return nil, err
	}

	// Process large CSV files
	var splitErr error

Review comment (suggestion):
```suggestion
				// If a csv file is overlarge, we need to split it into multiple
				// regions. This can only be done for uncompressed files with
				// strict format. Besides, the check threshold is increased by 1/10
				// of the `max-region-size` to avoid splitting small chunks,
				// because tools like dumpling may dump files whose size is slightly
				// exceed the `max-region-size`.
```
i prefer to format comments to be around 80 chars, you can add a visual guide like this one
<img width="2160" height="376" alt="image" src="https://github.com/user-attachments/assets/27fe9ed2-7c30-4cf3-a94a-50eb5a368bf3" />


Code after:
	var (
		largeFiles             sync.Map
		parallelSplitThreshold = cfg.MaxChunkSize * int64(concurrency)
	)

	for _, info := range meta.DataFiles {
		eg.Go(func() error {
			select {
			case <-egCtx.Done():
				return egCtx.Err()
			default:
			}

			var (
				regions []*TableRegion
				sizes   []float64
				err     error
			)
			if info.FileMeta.Type == SourceTypeParquet {
				regions, sizes, err = makeParquetFileRegion(egCtx, cfg, info)
			} else if info.FileMeta.Type == SourceTypeCSV && cfg.StrictFormat &&
				info.FileMeta.Compression == CompressionNone &&
				info.FileMeta.FileSize > cfg.MaxChunkSize+cfg.MaxChunkSize/largeCSVLowerThresholdRation {
				// If a csv file is overlarge, we need to split it into multiple
				// regions. This can only be done for uncompressed files with
				// strict format. Besides, the check threshold is increased by
				// 1/10 of the `max-region-size` to avoid splitting small chunks,
				// because tools like dumpling may dump files whose size is
				// slightly exceed the `max-region-size`.
				if info.FileMeta.FileSize > parallelSplitThreshold {
					// For extremely large csv files, we split them later.
					largeFiles.Store(info.FileMeta.Path, info)
					return nil
				}
				regions, sizes, err = SplitLargeCSV(ctx, cfg, info, false)
			} else {
				regions, sizes, err = MakeSourceFileRegion(egCtx, cfg, info)
			}
			if err != nil {
				logutil.Logger(egCtx).Error("make source file region error", zap.Error(err), zap.String("file_path", info.FileMeta.Path))
				return err
			}
			result := fileRegionRes{info: info, regions: regions, sizes: sizes, err: err}
			fileRegionsMap.Store(info.FileMeta.Path, result)
			return nil
		})
	}

	if err := eg.Wait(); err != nil {
		return nil, err
	}