FindFirstFileW repeatedly searches PATH instead of caching results, causing major performance degradation in DBF access

Questions about Wine on Linux
Post Reply
tomascribb
Newbie
Newbie
Posts: 1
Joined: Tue May 27, 2025 6:03 pm

FindFirstFileW repeatedly searches PATH instead of caching results, causing major performance degradation in DBF access

Post by tomascribb »

Description:
I’ve encountered a performance bottleneck when running a legacy Visual FoxPro application under Wine. The root cause appears to be how FindFirstFileW (or similar file resolution functions) handle repeated file access through relative paths.

Use Case:
The following simplified FoxPro-style logic simulates our routine:
*****
SCAN FOR RECNO() < 5000
SCATTER MEMO NAME m.loReg
FOR m.lnIte = 2 TO 9
SELECT 0
USE ("LOG000" + ALLTRIM(STR(m.lnIte)) + ".DBF")
IF PROCESSID % 2 = 0
INSERT INTO (ALIAS()) FROM NAME m.loReg
ELSE
GO BOTTOM
IF .NOT. EOF()
GATHER MEMO NAME m.loReg
ENDIF
ENDIF
USE
ENDFOR
SELECT PPAL
ENDSCAN
****
This code opens a series of .DBF files (like LOG0002.DBF to LOG0009.DBF) thousands of times in a loop. On Windows, this runs fairly quickly.

Problem:
Under Wine, this same code runs significantly slower — 5x to 10x slower — due to the way Wine handles file lookup. Each time a .DBF file is opened, Wine appears to search the full PATH (as defined in the environment or via config) without caching previous resolution results.

This results in:

Repeated directory traversal and file system stat() calls.

Poor performance when opening the same file repeatedly using the same relative name.

Significantly slower behavior compared to native Windows.

Expected Behavior:
Wine should cache the full path of recently accessed files (especially when the filename and working directory remain unchanged) instead of re-resolving them through the full PATH on every call. This would dramatically improve performance in loops like the one above.

Suggestion:
Implement a simple file resolution cache in kernelbase/file.c (or related layer) to avoid redundant searches through PATH for identical file names. This cache could be limited in size and cleared periodically, or invalidated by directory changes.

System Info:
Wine version: 10.0

OS: Ubuntu 24.01

Application: Visual FoxPro 9 (legacy)

Filesystem: ext4 on SSD
Post Reply