libfuse/example
Bernd Schubert af5710e7a3 fuse-loop/fuse_do_work: Avoid lots of thread creations/destructions
On benchmarking metadata operations with a single threaded bonnie++
and "max_idle_threads" limited to 1, 'top' was showing suspicious
160% cpu usage.
Profiling the system with flame graphs showed that an astonishing
amount of CPU time was spent in thread creation and destruction.

After verifying the code it turned out that fuse_do_work() was
creating a new thread every time all existing idle threads
were already busy. And then just a few lines later after processing
the current request it noticed that it had created too many threads
and destructed the current thread. I.e. there was a thread
creation/destruction ping-pong.

Code is changed to only create new threads if the max number of
threads is not reached.

Furthermore, thread destruction is disabled, as creation/destruction
is expensive in general.

With this change cpu usage of passthrough_hp went from ~160% to
~80% (with different values of max_idle_threads). And bonnie
values got approximately faster by 90%. This is a with single
threaded bonnie++
bonnie++ -x 4 -q -s0  -d <path> -n 30:1:1:10 -r 0

Without this patch, using the default max_idle_threads=10 and just
a single bonnie++ the thread creation/destruction code path is not
triggered.  Just one libfuse and one application thread is just
a corner case - the requirement for the issue was just
n-application-threads >= max_idle_threads.


Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04 13:07:15 +01:00
..
.gitignore Allow inode cache invalidation in high-level API 2017-08-24 14:20:37 +02:00
cuse_client.c examples/cuse_client: add include file to eliminate compiler warning (#568) 2020-11-24 09:28:13 +00:00
cuse.c Cuse example: Fix memory leak (#607) 2021-06-09 09:04:41 +01:00
cxxopts.hpp Bump cxxopts from 2.2.0 to 2.2.1 (#602) 2021-05-09 10:00:57 +01:00
hello_ll.c Updated example code to work with new API (#547) 2020-09-09 20:17:06 +01:00
hello.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
invalidate_path.c Fix doxygen warnings. (#600) 2021-05-07 10:43:30 +01:00
ioctl_client.c examples/cuse_client: add include file to eliminate compiler warning (#568) 2020-11-24 09:28:13 +00:00
ioctl.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
ioctl.h State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
meson.build Do not require C++ compiler for building 2020-04-20 20:20:19 +01:00
notify_inval_entry.c Updated example code to work with new API (#547) 2020-09-09 20:17:06 +01:00
notify_inval_inode.c Updated example code to work with new API (#547) 2020-09-09 20:17:06 +01:00
notify_store_retrieve.c Updated example code to work with new API (#547) 2020-09-09 20:17:06 +01:00
null.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
passthrough_fh.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
passthrough_helpers.h passthrough: fix unix-domain sockets on FreeBSD (#413) 2019-05-15 21:35:57 +01:00
passthrough_hp.cc fuse-loop/fuse_do_work: Avoid lots of thread creations/destructions 2022-09-04 13:07:15 +01:00
passthrough_ll.c Passthrough_ll should display cmd line options 2022-04-08 15:36:01 +01:00
passthrough.c Fix returning d_ino and d_type by readdir(3) in non-plus mode 2021-03-18 09:52:30 +00:00
poll_client.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
poll.c State GPL version in comment (#485) 2020-03-13 16:46:44 +00:00
printcap.c Removed duplicates code. (#642) 2022-02-11 20:07:00 +00:00