Skip to content

Commit 3de90b9

Browse files
committed
ls/BENCHMARKING.md: Add some tricks
1 parent cd4cb43 commit 3de90b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/uu/ls/BENCHMARKING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Benchmarking ls
22

33
ls majorly involves fetching a lot of details (depending upon what details are requested, eg. time/date, inode details, etc) for each path using system calls. Ideally, any system call should be done only once for each of the paths - not adhering to this principle leads to a lot of system call overhead multiplying and bubbling up, especially for recursive ls, therefore it is important to always benchmark multiple scenarios.
4+
5+
ls _also_ prints a lot of information, so optimizing formatting operations is also critical:
6+
- Try to avoid using `format` unless required.
7+
- Try to avoid repeated string copies unless necessary.
8+
- If a temporary buffer is required, try to allocate a reasonable capacity to start with to avoid repeated reallocations.
9+
- Some values might be expensive to compute (e.g. current line width), but are only required in some cases. Consider delaying computations, e.g. by wrapping the evaluation in a LazyCell.
10+
411
This is an overview over what was benchmarked, and if you make changes to `ls`, you are encouraged to check
512
how performance was affected for the workloads listed below. Feel free to add other workloads to the
613
list that we should improve / make sure not to regress.

0 commit comments

Comments
 (0)