[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Experiment with threads - no concurrency?
From: |
Arthur Miller |
Subject: |
Experiment with threads - no concurrency? |
Date: |
Mon, 06 Sep 2021 16:35:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
I did a little experiment today. I wanted to count frequency of Emacs functions
usage. So I started by indexing all functions and macros.
Since it is kind of lot's of I/O and independent tasks to do, I thought threads
could come handy. However I see no difference from sequential code.
I tried different versions, one where I did a single call to
directory-files-recursively, and than used one thread per file, to parse each
file separately, in own thread, but it was the slowest version. When I used to
code in Java long time ago, I used to see improvement in this kind of jobs due
to I/O. Maybe I am missunderstanding Emacs threads here?
In second version, I do two calls to directory-files-recursively, each in it's
own thread and use only two threads to do all the work, one per list. It is
slightly faster, but just slightly and still slower than pure sequential
version.
I have also inserted thread-yield statements so that all threads get chance to
run, but I see very little difference. Measured difference is probably due to
system fluctuation, rather than truly beacuse of thread scheduling (~0.1 sec on
a job of ~10 secs).
So, how to use threads in Emacs correctly? Is this me or is there just no
benefit of current thread implementation in Emacs? Sorry I don't mean to be rude
on thread implementation, but I am in doubt, should I just forgett about threads
or is there something I missunderstand about how to use them correctly?
The attached program is just about parsing files in emacs lisp dir for function
and macro defs (no frequency counting).
func-freq.el
Description: Text document
- Experiment with threads - no concurrency?,
Arthur Miller <=