DirectoryList listInfo="path" is slow

Description

there's a fast path used for `listinfo="name"`, it's just not being used for `listInfo="path"`

Before
DirectoryList listInfo="query" 2,842 C:\work\lucee-docs\api\data\PageCache.cfc
DirectoryList listInfo="path" 2,571 C:\work\lucee-docs\api\data\PageCache.cfc
DirectoryList listInfo="name" 599 C:\work\lucee-docs\api\data\PageCache.cfc

After
DirectoryList listInfo="query" 2,363 C:\work\lucee-docs\api\data\PageCache.cfc
DirectoryList listInfo="path" 582 C:\work\lucee-docs\api\data\PageCache.cfc
DirectoryList listInfo="name" 542 C:\work\lucee-docs\api\data\PageCache.cfc

Environment

None

Activity

Show:
Zac Spitzer
March 31, 2021, 4:18 PM
Edited

Turns out GetFileAttributes is slow (20% of overhead), it reads attributes one at a time (2x per file on windows)

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/runtime/tag/Directory.java#L844

The current approach goes thru up super method, which does also does invalid and security manager checks (3)

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/commons/io/res/type/file/FileResource.java#L600

Instead, it could use getAttribute(), but ideally we shouldn’t need to do this 2x per file / directory, i.e. better would be a getAttributes()

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/commons/io/res/type/file/FileResource.java#L704

Zac Spitzer
March 25, 2021, 6:04 PM

Assignee

Michael Offner

Reporter

Zac Spitzer

Priority

New

Fix versions

None