Skip to content

Slow message loading #403

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

Open
skurrilewelt opened this issue May 11, 2023 · 5 comments
Open

Slow message loading #403

skurrilewelt opened this issue May 11, 2023 · 5 comments

Comments

@skurrilewelt
Copy link

Hi,

some folks reported slow message fetching and all tickets are closed but there is no solution mentioned. I tried both v4 and v5. The bottle neck is looping through paginated messages and takes 8 to 10 sec for 20 messages.
Maybe I'm doing wrong but in my code everything is similar more or less to the example code. Even if I leave everything out in the foreach loop there is no improvement.

Maybe someone has any clue?

@firecrauter
Copy link

Hi,

some folks reported slow message fetching and all tickets are closed but there is no solution mentioned. I tried both v4 and v5. The bottle neck is looping through paginated messages and takes 8 to 10 sec for 20 messages. Maybe I'm doing wrong but in my code everything is similar more or less to the example code. Even if I leave everything out in the foreach loop there is no improvement.

Maybe someone has any clue?

The only way I know is to put the PHP code, in the same hosting you aim.
4 seconds took, now ~ 300ms.
(If it is Gmail/Hotmail, perhaps forwarding an email of your domain and there to use this project)

@skurrilewelt
Copy link
Author

skurrilewelt commented Feb 21, 2024

I made some tests with another imap library which depends on build-in php imap methods and builds some classes upon them. The test setup uses both the simplest example code given by the contributors.
Connecting to the same account and same mailbox, fetching 62 Messages, most of them with one or more attachments, looping through messages and display subject and number of attachments. Results:

PHP7.4.23 Webklex 4.1.2 => 29 sec, DDeboer => 0.7 sec
PHP8.1.6 Webklex 5.3 => 91 sec, DDeboer =>0.7 sec

I repeated this tests several times with no significant differences in result.

So it seems that there is no performance enhancement in version 5.

Maybe someone can explain this or has any idea how to improve webklex' performance because this lib is really awesome in al other aspects.

@osamasc
Copy link

osamasc commented Jun 6, 2024

Would you happen to have any updates?
i guess the problem is this line
while (($next_char = fread($this->stream, 1)) !== false && !in_array($next_char, ["","\n"])) {
it loops for 20,000 times calling fread not sure if this is correct!
which lib do you use now?

I made some tests with another imap library which depends on build-in php imap methods and builds some classes upon them. The test setup uses both the simplest example code given by the contributors. Connecting to the same account and same mailbox, fetching 62 Messages, most of them with one or more attachments, looping through messages and display subject and number of attachments. Results:

PHP7.4.23 Webklex 4.1.2 => 29 sec, DDeboer => 0.7 sec PHP8.1.6 Webklex 5.3 => 91 sec, DDeboer =>0.7 sec

I repeated this tests several times with no significant differences in result.

So it seems that there is no performance enhancement in version 5.

Maybe someone can explain this or has any idea how to improve webklex' performance because this lib is really awesome in al other aspects.

@mauserrifle
Copy link

Same issue here. Indeed the nextLine method is the issue. It is extremely slow. For now I changed my application to not fetch message bodies in overviews and limit the number with pagination. It would be great if this could be solved. Maybe through a commercial way? (e.g. paid development).

@wurst-hans
Copy link
Contributor

wurst-hans commented May 7, 2025

@osamasc @mauserrifle Same for me. It's terribly slow when retrieving emails having attachments. I made a pull request (#576).

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

No branches or pull requests

5 participants