[bug] Fast-HTML uses 100% of a core, reducing performance and causing issues. #843

Open
opened 2024-10-23 19:01:37 +00:00 by ari · 2 comments

Your setup

OTP

Extra details

Debian Linux.

Version

3.13.2-0-g050bc74

PostgreSQL version

15

What were you trying to do?

Akkoma, at some point, ends up using 100% of a CPU core in the Fast-HTML library calls. This is an issue and causes performance problems and I don't think this is intended behaviour, since it is persistent in long-term, but disappears for some time after a restart.

image

What did you expect to happen?

For it to not use 1 CPU core constantly or, if it is intended, to persist after a restart.

What actually happened?

It kept using 1 CPU core, and disappeared after a restart, although, I believe this is likely to come back.

Logs

In relation to this problem we also have these logs:

```
Oct 23 18:40:31 mail pleroma[3689935]: ** (FunctionClauseError) no function clause matching in FastHtml.Pool.handle_info/2
Oct 23 18:40:31 mail pleroma[3689935]:     (fast_html 2.3.0) lib/fast_html/pool.ex:123: FastHtml.Pool.handle_info({#Port<0.278080>, {:exit_status, 143}}, #Port<0.278157>)
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:1083: NimblePool.do_apply_worker_callback/4
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:813: anonymous fn/5 in NimblePool.maybe_handle_info/2
Oct 23 18:40:31 mail pleroma[3689935]:     (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:811: NimblePool.maybe_handle_info/2
Oct 23 18:40:31 mail pleroma[3689935]:     (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
Oct 23 18:40:31 mail pleroma[3689935]:     (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
Oct 23 18:40:31 mail pleroma[3689935]:     (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
...
Oct 23 18:40:31 mail pleroma[3689935]: 18:40:31.017 [error] Error during FastHtml.Pool.terminate_worker/3 callback:
Oct 23 18:40:31 mail pleroma[3689935]: ** (ArgumentError) argument error
Oct 23 18:40:31 mail pleroma[3689935]:     :erlang.port_close(#Port<0.278140>)
Oct 23 18:40:31 mail pleroma[3689935]:     (fast_html 2.3.0) lib/fast_html/pool.ex:98: FastHtml.Pool.terminate_worker/3
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:1083: NimblePool.do_apply_worker_callback/4
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:1018: NimblePool.maybe_terminate_worker/3
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:917: NimblePool.remove_worker/3
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:819: anonymous fn/5 in NimblePool.maybe_handle_info/2
Oct 23 18:40:31 mail pleroma[3689935]:     (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
Oct 23 18:40:31 mail pleroma[3689935]:     (nimble_pool 1.1.0) lib/nimble_pool.ex:811: NimblePool.maybe_handle_info/2
```

Severity

I can manage

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup OTP ### Extra details Debian Linux. ### Version 3.13.2-0-g050bc74 ### PostgreSQL version 15 ### What were you trying to do? Akkoma, at some point, ends up using 100% of a CPU core in the Fast-HTML library calls. This is an issue and causes performance problems and I don't think this is intended behaviour, since it is persistent in long-term, but disappears for some time after a restart. ![image](/attachments/90f16165-6bd3-48f6-a67f-a8dd6cd5bbfa) ### What did you expect to happen? For it to not use 1 CPU core constantly or, if it is intended, to persist after a restart. ### What actually happened? It kept using 1 CPU core, and disappeared after a restart, although, I believe this is likely to come back. ### Logs ````shell In relation to this problem we also have these logs: ``` Oct 23 18:40:31 mail pleroma[3689935]: ** (FunctionClauseError) no function clause matching in FastHtml.Pool.handle_info/2 Oct 23 18:40:31 mail pleroma[3689935]: (fast_html 2.3.0) lib/fast_html/pool.ex:123: FastHtml.Pool.handle_info({#Port<0.278080>, {:exit_status, 143}}, #Port<0.278157>) Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:1083: NimblePool.do_apply_worker_callback/4 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:813: anonymous fn/5 in NimblePool.maybe_handle_info/2 Oct 23 18:40:31 mail pleroma[3689935]: (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:811: NimblePool.maybe_handle_info/2 Oct 23 18:40:31 mail pleroma[3689935]: (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3 Oct 23 18:40:31 mail pleroma[3689935]: (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6 Oct 23 18:40:31 mail pleroma[3689935]: (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3 ... Oct 23 18:40:31 mail pleroma[3689935]: 18:40:31.017 [error] Error during FastHtml.Pool.terminate_worker/3 callback: Oct 23 18:40:31 mail pleroma[3689935]: ** (ArgumentError) argument error Oct 23 18:40:31 mail pleroma[3689935]: :erlang.port_close(#Port<0.278140>) Oct 23 18:40:31 mail pleroma[3689935]: (fast_html 2.3.0) lib/fast_html/pool.ex:98: FastHtml.Pool.terminate_worker/3 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:1083: NimblePool.do_apply_worker_callback/4 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:1018: NimblePool.maybe_terminate_worker/3 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:917: NimblePool.remove_worker/3 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:819: anonymous fn/5 in NimblePool.maybe_handle_info/2 Oct 23 18:40:31 mail pleroma[3689935]: (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3 Oct 23 18:40:31 mail pleroma[3689935]: (nimble_pool 1.1.0) lib/nimble_pool.ex:811: NimblePool.maybe_handle_info/2 ``` ```` ### Severity I can manage ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
ari added the
bug
label 2024-10-23 19:01:37 +00:00
Contributor

A new version of fast_html was released last month. The changelog says it updated lexbor to 2.4.0, and lexbor's changelog mentions improved performance. Perhaps worth upgrading the dependency in that case.

A new version of fast_html [was released](https://git.pleroma.social/pleroma/elixir-libraries/fast_html/-/blob/master/CHANGELOG.md?ref_type=heads) last month. The changelog says it updated lexbor to 2.4.0, and [lexbor's changelog](https://github.com/lexbor/lexbor/blob/master/CHANGELOG.md) mentions improved performance. Perhaps worth upgrading the dependency in that case.
Author

A new version of fast_html was released last month. The changelog says it updated lexbor to 2.4.0, and lexbor's changelog mentions improved performance. Perhaps worth upgrading the dependency in that case.

could be, it is still a problem, i'll wait for the next binary release and hope it'll work since we don't build it from source :)

> A new version of fast_html [was released](https://git.pleroma.social/pleroma/elixir-libraries/fast_html/-/blob/master/CHANGELOG.md?ref_type=heads) last month. The changelog says it updated lexbor to 2.4.0, and [lexbor's changelog](https://github.com/lexbor/lexbor/blob/master/CHANGELOG.md) mentions improved performance. Perhaps worth upgrading the dependency in that case. could be, it is still a problem, i'll wait for the next binary release and hope it'll work since we don't build it from source :)
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#843
No description provided.