Comments (4)
I will write what I would do, but feel free to take the approach you prefer:
In order to optimize only what needs to be optimized, I would write a simple unittest-like program that loads the Mycroft voice from a file and prints the time it takes to load it. Then I would run it several times to get an estimate of the performance on my computer.
Then I would try those optimizations from easier to harder.
- inline functions seems easy but if the compiler is smart enough it should do it automatically so I don't expect a huge gain there. I don't know how smart compilers are, so I may be wrong here.
- I have never used setvbuf but if it is easy to setup it should reduce many internal read calls. It may be good.
- Reducing the number of cst_fread calls is possible up to a limit due to how the file format is set up. Strings are of variable length so I don't know how much can that be optimized.
I believe the slowness is due to either:
- too many small reads from file (would be solved by setvbuf)
- too many small cst_alloc calls when creating the cart trees. The solution for this would be to have a big malloc and put several tree nodes all together in there somehow...
- too many function calls in general. If that is the case we will need to think of a better format for dumping/loading cart trees...
Hope I can be of help!
from mimic1.
Thanks for the suggestions. I am also sceptical to inlining the function calls as you say the compiler should be smart enough. Maybe just make them static so the compiler can optimize correctly even when making shared library. (Maybe it already can without static, I'm not up to date with how compiler works nowadays)
I've tried two things so far:
setting a 64k buffer with cstvbuf()
reduced read operations from ~17000 down to ~1500 which may be significant for platforms like the raspberry pi. But I could only see a ~5% improvement in loading times on my computer.
Replace the four initial cst_fread()
with a single in cst_read_tree_nodes()
. No effect on the number of read operations but according to my time measurements the speed improvement is ~10%
I'll look into some sort of block memory allocation.
from mimic1.
Small update, I've tried a bunch of minor changes. On my machine I can see ~25% performance improvement.
What I've done:
- Some more minor function optimizations except for the ones stated above gave a couple of percent each
- Replace
cst_alloc()
(which usescalloc()
) withmalloc()
further improves things.
Next steps will be
- a simple block allocator
- try to mmap the file
from mimic1.
I have around 300MB of free memory on my pi to play with...would a ramdisk help the loading time of the libraries?
I ran a trace with this
strace -o strace ./mimic test
Then did...
cat strace | grep /home/pi/mycroft-core/mimic/lib
cat strace | grep /home/pi/mycroft-core/mimic/.lib
I don't know much about the program but if some of the libraries can be put onto a ramdisk it might help with the performance.
from mimic1.
Related Issues (20)
- Publish prebuilt mimic releases HOT 2
- windows cross-compilation instructions are not exact. HOT 2
- Problem with speaking. HOT 7
- Voice is not playing over bluetooth HOT 3
- Where is the difference between Mimic and Flite? HOT 2
- Linking fails, but easily fixed HOT 2
- Add support for Palm OS HOT 2
- Unable to make standalone mimic pause and resume at will when reading long text from terminal HOT 5
- Compile for pulseaudio HOT 2
- Using mimic libraries HOT 11
- Distorted 'ap' voice output when compiling with gcc 8.3
- mimic -p '' segs HOT 1
- Tool for creating my own .flitevox? HOT 4
- Dead links: festvox.org doesn't work anymore? HOT 3
- Is there a guide for adding new language support to mimic1? HOT 1
- Windows cross compilation error
- Issue while compiling with LTO enabled HOT 1
- Error when running 'make' HOT 5
- At ./autogen.sh: syntax error near unexpected token `newline'
- "Shared" compilation (with --enable-shared=yes) fails. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mimic1.