-
Notifications
You must be signed in to change notification settings - Fork 24
Use on_load module attribute #14
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
Conversation
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 also just noticed, this makes starting the app 100x faster, see starting a release with |
|
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. |
b493aa4 to
955861b
Compare
|
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? 🤔 |
Aha, great, Thanks!
As ejabberd lowest supported version right now is OTP 20.0, I see no need to test with lower versions. |
|
Ok, just managed to get testing on OTP19 too exactly as you were writing! Can remove it too, just let me know 🙂 |
|
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 ;) |
3e54bf3 to
955861b
Compare
|
Done 👌🏽 Looking forward for a new release 😉 |
|
@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 :) |
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_infoheads of the gen_server is even a remnant of the times whenfast_tlswas 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_tlsa long time ago here: processone/fast_tls#43