Bug #117943 Startup ibd-file validation uses too much CPU threads
Submitted: 11 Apr 8:07 Modified: 11 Apr 10:44
Reporter: Tsubasa Tanaka (OCA) Email Updates:
Status: Analyzing Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.4.4, 9.2.0 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[11 Apr 8:07] Tsubasa Tanaka
Description:
When starting up mysqld process, mysqld runs ibd-file validation ( controlled by innodb_validate_tablespace_paths )

This procedure is paralellized, but seems too much CPU threads.
Following log is printed on box which has 8 vCPUs.

```
2025-04-10T10:32:25.069134-00:00 0 [Note] [MY-012350] [InnoDB] 16threads have validated 42600 out of 200008 tablespaces so far.
```

I think "std::thread::hardware_concurrency" returns "How many CPU *threads* to use",  already considered about SMT (ex. Hyperthreading) .
Therefore, FIL_SCAN_THREADS_PER_CORE(Hardcoded as 2) * std::thread::hardware_concurrency() is too much number of threads.

https://github.com/mysql/mysql-server/blob/mysql-9.2.0/storage/innobase/fil/fil0fil.cc#L14...

How to repeat:
- Create tables more than FIL_SCAN_MAX_TABLESPACES_PER_THREAD(Hardcoded as 8000 in MySQL 9.2.0) * vCPU cores.

- Start mysqld
- Observe LoadAvg and %sys during startup

Suggested fix:
Remove to multiply by FIL_SCAN_THREADS_PER_CORE