Skip to content

_seek_to_end() performance up - #357

Closed
coregear wants to merge 1 commit into
python-beaver:masterfrom
coregear:master
Closed

_seek_to_end() performance up#357
coregear wants to merge 1 commit into
python-beaver:masterfrom
coregear:master

Conversation

@coregear

Copy link
Copy Markdown

linux only, use "/usr/bin/wc" instead native python code, to solve startup very slow problem.

linux only, use "/usr/bin/wc" instead native python code, to solve startup very slow problem.
@kitchen

kitchen commented Nov 25, 2015

Copy link
Copy Markdown
Contributor

Hey, thanks for your PR!

I get the motivation here. The old approach is not great. Hardcoding a path to wc, as well as other things, just smells wrong.

Looking at the code, it seems like it's trying to find the end of the last line in the file? And to do so it's just reading every line in the file until it runs out of lines. I think this is so it ends on a newline or something.

Perhaps have it seek to end, and start searching backward for lines to be read by readline(). If it can't find one, seek back further and do it again. Maybe in ~1024 byte chunks?

Seek to end. rewind 1024 bytes. readline until complete, return. If no readline in that 1024 bytes, go back 2048, rinse repeat.

Just a guess, @josegonzalez would probably have better input on what this code is actually trying to do :)

@JamieCressey

Copy link
Copy Markdown
Member

Agreed, @kitchen's idea seems more reasonable. Would you have chance to update the PR, @coregear ?

@JamieCressey

Copy link
Copy Markdown
Member

Closing due to inactivity. Feel free to reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants