Skip to content
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

Upstream truffleruby patches needed when using system libraries #2663

Merged
merged 5 commits into from
Oct 14, 2022

Conversation

eregon
Copy link
Contributor

@eregon eregon commented Oct 12, 2022

  • Adapt tests for that configuration.

What problem is this PR intended to solve?

#2491

Have you included adequate test coverage?

Yes.

Does this change affect the behavior of either the C or the Java implementations?

Only C, no need to change Java code.

@eregon
Copy link
Contributor Author

eregon commented Oct 12, 2022

This should fix this currently-failing CI job: https://github.com/sparklemotion/nokogiri/actions/runs/3217744062/jobs/5261075281

@eregon eregon force-pushed the upstream-truffleruby-patches branch from d5e129f to 5877756 Compare October 12, 2022 18:14
@flavorjones
Copy link
Member

Thanks for shipping this! I'll take a look shortly.

@flavorjones
Copy link
Member

Normally we don't run the suite against TR for every commit (because it takes so long we opt for a cron job), so I've just pushed a commit that tries to make sure CI will run TR when branch names have "truffle" in them.

@eregon
Copy link
Contributor Author

eregon commented Oct 12, 2022

Normally we don't run the suite against TR for every commit (because it takes so long we opt for a cron job), so I've just pushed a commit that tries to make sure CI will run TR when branch names have "truffle" in them.

Right. Since there is workflow_dispatch I should be able to schedule it on my fork manually.

BTW for test speed, the main cost is the default NOKOGIRI_TEST_GC_LEVEL=major. Without that tests execute in just 1 minute for me locally. So maybe we should set NOKOGIRI_TEST_GC_LEVEL=normal for TruffleRuby, or GC less often and then we could run it in the gate/more often?

@eregon
Copy link
Contributor Author

eregon commented Oct 12, 2022

@eregon
Copy link
Contributor Author

eregon commented Oct 12, 2022

Given these test times over 1 hour yeah I think we should definitely force GC less often 😅
We can do that separately though, I can try it on a branch tomorrow with NOKOGIRI_TEST_GC_LEVEL=normal for comparison.

@@ -203,10 +203,16 @@ warning_func(void *ctx, const char *msg, ...)
VALUE doc = rb_iv_get(self, "@document");
VALUE rb_message;

#ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
/* It is not currently possible to pass var args from native
functions to sulong, so we work around the issue here. */
Copy link
Contributor Author

@eregon eregon Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've asked the TruffleNFI/Sulong team about that (@rschatz), and it sounds like a limitation of libffi (can't read varargs from a libffi callback), so probably nothing we can do about it in the short term.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* That is causing too much overhead.
@eregon
Copy link
Contributor Author

eregon commented Oct 13, 2022

We can do that separately though, I can try it on a branch tomorrow with NOKOGIRI_TEST_GC_LEVEL=normal for comparison.

It runs in ~3min (with --enable-system-libraries) and ~8-9min (without): https://github.com/eregon/nokogiri/actions/runs/3241791089/jobs/5314201500
I'll push that on this PR too, but feel free to remove it if you want to keep it for these jobs.

I'm unsure how useful it is to GC between tests on TruffleRuby. I would say not worth it given the huge overhead.
Marking actually happens when leaving a C ext method in TruffleRuby, not during the JVM GC, and to detect a problem we need to execute code using e.g. a freed handle. The GC between tests makes it rather unlikely to reuse such a handle, so for TruffleRuby I'd think GCs happening during the tests (which already occur naturally) are more useful to detect this kind of bugs.

@flavorjones
Copy link
Member

Yes, the GC settings are there primarily to exercise CRuby and I wasn't even aware that TruffleRuby supported those settings. Please do feel free to add a commit that restores normal GC behavior for TR.

I have a terribly busy day today, but I will circle back to this by the weekend. I'm glad we're green and look forward to staying green!

@flavorjones flavorjones merged commit 4e7ffd9 into sparklemotion:main Oct 14, 2022
@flavorjones
Copy link
Member

Thank you, @eregon!

@eregon eregon deleted the upstream-truffleruby-patches branch October 14, 2022 12:25
@eregon
Copy link
Contributor Author

eregon commented Oct 14, 2022

Thank you for merging!

I plan to remove the patches in TruffleRuby after the next nokogiri release, because they shouldn't be needed anymore, they are currently only needed when using system libraries, and with this PR won't be necessary for future nokogiri versions (when using system libraries).
When using packaged libraries (the default) there is already no patching.

@flavorjones
Copy link
Member

OK. If it's helpful, for managing upstream version checks, these changes will show up in Nokogiri 1.14.0.

@flavorjones flavorjones added this to the v1.14.0 milestone Oct 14, 2022
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.

2 participants