Skip to content

kernel: turn global GAP and module states back into static globals#6376

Open
fingolfin wants to merge 2 commits intomasterfrom
mh/eliminate-module-states
Open

kernel: turn global GAP and module states back into static globals#6376
fingolfin wants to merge 2 commits intomasterfrom
mh/eliminate-module-states

Conversation

@fingolfin
Copy link
Copy Markdown
Member

... at least in plain GAP; keep them as before in HPC-GAP.

The whole concept was invented to allow HPC-GAP to have thread local GAP and module state. In plain GAP, though, it introduced some minor overhead.

Changing this here allows us to avoid the overhead, and it also prevents GAPState from becoming larger than 32kb. This can happen on platforms with a large jmp_buf (e.g., powerpc64).

Alternative to and hence closes #6373

@fingolfin fingolfin requested a review from ChrisJefferson May 7, 2026 21:41
@fingolfin fingolfin added topic: kernel release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels May 7, 2026
@fingolfin fingolfin marked this pull request as draft May 7, 2026 21:44
@fingolfin
Copy link
Copy Markdown
Member Author

Note to self: if we decide to merge this, then make sure to increment kernel_major_version in this PR, too

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 67.87330% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.69%. Comparing base (400a52d) to head (f058092).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/io.c 43.22% 62 Missing and 5 partials ⚠️
src/objcftl.c 66.66% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6376   +/-   ##
=======================================
  Coverage   78.69%   78.69%           
=======================================
  Files         684      683    -1     
  Lines      292892   292901    +9     
  Branches     8665     8658    -7     
=======================================
+ Hits       230494   230509   +15     
+ Misses      60577    60570    -7     
- Partials     1821     1822    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fingolfin fingolfin marked this pull request as ready for review May 9, 2026 09:24
... at least in plain GAP; keep them as before in HPC-GAP.

The whole concept was invented to allow HPC-GAP to have thread
local GAP and module state. In plain GAP, though, it introduced
some minor overhead.

Changing this here allows us to avoid the overhead, and it also
prevents GAPState from becoming larger than 32kb. This can happen
on platforms with a large jmp_buf (e.g., powerpc64).
@fingolfin fingolfin force-pushed the mh/eliminate-module-states branch from e902c84 to eef8286 Compare May 9, 2026 09:30
Comment thread src/modules.h
Comment on lines +93 to +104
#ifdef HPCGAP
// number of bytes this module needs for its per-thread module state
// Only used in HPC-GAP, but not behind an #ifdef guard to avoid API
// breakage for C++ kernel extensions
UInt moduleStateSize;

// if this is not zero, then the module state offset is stored into
// the address this points at
// Only used in HPC-GAP, but not behind an #ifdef guard to avoid API
// breakage for C++ kernel extensions
Int * moduleStateOffsetPtr;
#endif
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ChrisJefferson FYI I've decided to disable the module state in "plain" GAP and only keep it for HPC-GAP (but not initModuleState because that is actually used even in "plain" GAP.

No GAP packages use it -- only PackageMaker's C++ template code as well as the gapbind14 kernel extension in Semigroups (which is just a demo, so it's not a big issue). I've already changes this in PackageMaker, and also submitter semigroups/Semigroups#1179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants