Skip to content

Conversation

@NelsonVides
Copy link
Contributor

Before OTP 19.0, if the on_load directive fails, any previously loaded code would become old, essentially leaving the system without any working and reachable instance of the module. This is not true anymore since OTP 19.0, so loading the nifs within the on_load directive is today the cleanest and best code pattern.

It seems indeed very convoluted to have an entire application and supervision tree with a worker gen_server just to load the nifs. Also, one of the handle_info heads of the gen_server is even a remnant of the times when fast_tls was implemented as a port driver instead of as nifs, which is a high sign this needed some modernisation.

I contributed a similar work for fast_tls a long time ago here: processone/fast_tls#43

Before OTP 19.0, if the on_load directive fails, any previously loaded
code would become old, essentially leaving the system without any
working and reachable instance of the module. This is not true anymore
since OTP 19.0, so loading the nifs within the on_load directive is
today the cleanest and best code pattern.

It seems indeed very convoluted to have an entire application and
supervision tree with a worker gen_server just to load the nifs. Also,
one of the `handle_info` heads of the gen_server is even a remnant of
the times when `fast_tls` was implemented as a port driver instead of as
nifs, which is a high sign this needed some modernisation.
@NelsonVides
Copy link
Contributor Author

I also just noticed, this makes starting the app 100x faster, see starting a release with ERL_FLAGS="-init_debug" for details.

@badlop
Copy link
Member

badlop commented Feb 12, 2025

I've checked that ejabberd passes all its own tests with this PR, using Erlang 20.0, 25, 26, 27.

You've updated ci.yml to test stringprep with Erlang 21 and higher. Why did you remove otp 20?

@NelsonVides
Copy link
Contributor Author

I've checked that ejabberd passes all its own tests with this PR, using Erlang 20.0, 25, 26, 27.

You've updated ci.yml to test stringprep with Erlang 21 and higher. Why did you remove otp 20?

It was giving me trouble with the checkout action and quickly thought it wasn't worth the effort for a probably deprecated version. Give me 5-10min to have a better look, maybe it's easier than I thought.

@NelsonVides NelsonVides force-pushed the use_on_load_directive branch from b493aa4 to 955861b Compare February 12, 2025 11:49
@NelsonVides
Copy link
Contributor Author

Right, OTP20 runs just fine, it just wasn't added to CI to begin with; the issue was on OTP19, then it gets annoying with ubuntu/docker/glibc compatibilities. Do you need testing in OTP19? 🤔

@badlop
Copy link
Member

badlop commented Feb 12, 2025

Right, OTP20 runs just fine, it just wasn't added to CI to begin with;

Aha, great, Thanks!

the issue was on OTP19, then it gets annoying with ubuntu/docker/glibc compatibilities. Do you need testing in OTP19? 🤔

As ejabberd lowest supported version right now is OTP 20.0, I see no need to test with lower versions.

@NelsonVides
Copy link
Contributor Author

Ok, just managed to get testing on OTP19 too exactly as you were writing! Can remove it too, just let me know 🙂

@badlop
Copy link
Member

badlop commented Feb 12, 2025

I guess almost nobody will use stringprep with Erlang/OTP lower than 20.0. Not even ejabberd supports such old versions.

Additionally, the Ubuntu 20.04 Actions runner image in GitHub will begin deprecation on 2025-02-01 and will be fully unsupported by 2025-04-01

In summary, you can drop testing for Erlang/OTP 19.3 ;)

@NelsonVides NelsonVides force-pushed the use_on_load_directive branch from 3e54bf3 to 955861b Compare February 12, 2025 12:21
@NelsonVides
Copy link
Contributor Author

Done 👌🏽

Looking forward for a new release 😉

@badlop badlop merged commit fd4bb9d into processone:master Feb 12, 2025
18 checks passed
@NelsonVides NelsonVides deleted the use_on_load_directive branch February 12, 2025 12:45
@coveralls
Copy link

coveralls commented Feb 13, 2025

Coverage Status

coverage: 86.275% (+2.0%) from 84.249%
when pulling 3e54bf3 on NelsonVides:use_on_load_directive
into 7688cf9 on processone:master.

@NelsonVides
Copy link
Contributor Author

@badlop hey there, any chance we can get a new release in hex? Just want to speed up startup times, but also hex packages fetch faster than github repos :)

@prefiks
Copy link
Member

prefiks commented Feb 21, 2025

https://hex.pm/packages/stringprep/1.0.31

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.

4 participants