fix: close issue #249 — Emscripten OOM in CKKS unit tests#1208
Open
BAder82t wants to merge 1 commit into
Open
Conversation
PR openfheorg#1179 added ClearBootstrapPrecom and ClearSchemeSwitchPrecom helpers but did not wire them into ReleaseAllContexts. This change completes that work, then re-enables the EVAL_FAST_ROTATION and CONTEXT_WITH_SERTYPE tests that PR openfheorg#985 had to guard under !defined(__EMSCRIPTEN__) for the original std::bad_alloc failure. Library changes (no hot-path touched): - ReleaseAllContexts now walks every live context and calls ClearAllCKKSCaches before clearing the static maps. - Add ReleaseAllContextsAndTrim and TrimAllocator (malloc_trim on glibc, malloc_zone_pressure_relief on Apple, _heapmin on MSVC, no-op else). - Add ClearAllCKKSCaches convenience on CryptoContextImpl. - ClearBootstrapPrecom and ClearSchemeSwitchPrecom bodies made noexcept-safe so the walk does not throw on contexts that have not Enable(FHE)'d or Enable(SCHEMESWITCH)'d. Test changes: - TearDown in UTCKKSrns and UTCKKSrnsSerialize now calls ReleaseAllContextsAndTrim. - Mid-test ClearAllCKKSCaches between JSON and BINARY rounds in UnitTestCKKSrnsSerialize. - UTCKKSCacheClear extends its WITH_TCM skip to __EMSCRIPTEN__ (the heap-probe helper has no emmalloc backend). - Remove the !defined(__EMSCRIPTEN__) guards around the affected rows. CI: - Add .github/workflows/emscripten.yml: builds with emsdk 3.1.59 and runs pke_tests/core_tests under node in two slices. Validated on macOS + WASM: - Native: pke_tests 1892/1892 pass, core_tests 158/158 pass. - WASM: CKKS slice 939/941 pass (2 heap-probe tests skipped), BFV+BGV+binfhe slice 324/324 pass, peak 1.6 GB. Closes openfheorg#249.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #249.
PR #1179 added the cache-clear helpers but didn't wire them into
ReleaseAllContexts. This wires the walk in, addsReleaseAllContextsAndTrim(malloc_trim/ Applepressure_relief/ MSVC_heapmin/ else no-op), makes the per-context clears noexcept-safe, and re-enables the 16 rows previously guarded under!__EMSCRIPTEN__(EVAL_FAST_ROTATION_41–48,CONTEXT_WITH_SERTYPE_01–08).UTCKKSCacheClearextends its existingWITH_TCMskip to__EMSCRIPTEN__— its heap probes rely onmallinfo2. Test fixtures move toReleaseAllContextsAndTrim. Newemscripten.ymlruns emsdk 3.1.59 + node slices so this can't go silent again.No hot-path file is touched.
Validated locally
pke_tests1892/1892,core_tests158/158.NATIVE_SIZE=64): the 16 re-enabled rows pass; CKKS slice 939/941 (2 heap-probe skips), BFV+BGV+binfhe 324/324; peak ~1.6 GB / 4 GB cap.