-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow documents for profiling #277
Comments
Not noticing much slowness on the emulator :) But this book is a bit different from most in that there are thousands of 969 323 / 21 could indicate there are 46142 crengine/crengine/src/lvrend.cpp Lines 3916 to 3948 in 621dee0
I guess just moving all the lines from Can you check and time it ?:) |
Except --- a/crengine/src/lvrend.cpp
+++ b/crengine/src/lvrend.cpp
@@ -3932,20 +3932,20 @@ void DrawDocument( LVDrawBuf & drawbuf, ldomNode * enode, int x0, int y0, int dx
// A few things differ when done for TR, THEAD, TBODY and TFOOT
bool isTableRowLike = rm == erm_table_row || rm == erm_table_row_group ||
rm == erm_table_header_group || rm == erm_table_footer_group;
- int em = enode->getFont()->getSize();
- int width = fmt.getWidth();
int height = fmt.getHeight();
- bool draw_padding_bg = true; //( enode->getRendMethod()==erm_final );
- int padding_left = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[0], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,3);
- int padding_right = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[1], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,1);
- int padding_top = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[2], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,0);
- //int padding_bottom = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[3], width, em ) + DEBUG_TREE_DRAW;
if ( (doc_y + height <= 0 || doc_y > 0 + dy) && !isTableRowLike ) {
// TR may have cells with rowspan>1, and even though this TR
// is out of range, it must draw a rowspan>1 cell, so it it
// not empty when a next TR (not out of range) is drawn.
return; // out of range
}
+ int em = enode->getFont()->getSize();
+ int width = fmt.getWidth();
+ bool draw_padding_bg = true; //( enode->getRendMethod()==erm_final );
+ int padding_left = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[0], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,3);
+ int padding_right = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[1], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,1);
+ int padding_top = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[2], width, em ) + DEBUG_TREE_DRAW+measureBorder(enode,0);
+ //int padding_bottom = !draw_padding_bg ? 0 : lengthToPx( enode->getStyle()->padding[3], width, em ) + DEBUG_TREE_DRAW;
css_length_t bg = enode->getStyle()->background_color;
lUInt32 oldColor = 0;
// Don't draw background color for TR and THEAD/TFOOT/TBODY as it could |
The path on the left of your image is there: crengine/crengine/src/lvtinydom.cpp Lines 12071 to 12102 in 621dee0
Same issue - top_margin & bottom_margin computed early - but less obvious to fix as these are used to decide about |
@poire-z Oh drat, so I didn't profile correctly! I noticed the slowness while tapping, but I didn't recreate the conditions properly by using page up/down for the profiling. Which isn't actually very slow. Except that slightly misleadingly, in Valgrind it is. |
No profiling yet, but your suggested changes do feel slightly more responsive. |
I'll probably PR the first one and include it in the coming crengine bump as it looks super safe. But all that could be furthermore optimised by caching many stuff in credocument (the buffer, the rects for links, the rects for highlights) so we don't request them from crengine when playing with the menu, dict lookup... |
Proper profile of the current code for potential future reference. Incidentally, on my desktop it's practically faster in Valgrind than on my laptop without. Quite sad. :-) And here it is with the changes: |
Looked at them, so a big rectangle on the left disappeared, and make all the other get bigger. So, I guess it's good :) |
Here's one that could potentially be worth a look. Via https://www.mobileread.com/forums/showthread.php?p=3870059#post3870059 |
Just a quick note, for info and "good to know": I'm reading a 67 KB small EPUB which results in 110 pages. It turns out this book (by Thomas Bernhard, dunno if he is known for that) is a single 110-pages paragraph - so crengine has to format this whole paragraph for drawing slices of it, which makes the re-opening as long as a re-rendering (after this opening, this formatting is cached in memory, so everything then is quick). |
By coincidence I came across this book, which seems to take a small eternity to change pages. (Okay, just a second, but that's a really long time.)
https://www.smashwords.com/books/view/631261
Anyway, so I figured I'd profile it. I'm not sure if that's helpful in this case but there you have it. ;-)
callgrind.out.12948.tar.gz
Same file as posted over at 8f15e01#r32965759
Btw, general remark, you can get the machine code with
--dump-instr=yes
, as invalgrind --tool=callgrind --dump-instr=yes ./reader.lua
.The text was updated successfully, but these errors were encountered: