Repository navigation
Conversation
Prefixes every line of the task backtrace dump with the ID of the thread that prints it. Keeps the t->ctx.stkbuf != NULL guards around the per-task backtrace. The first 1.13 port dropped them, so stackless tasks went through jl_record_backtrace and the "no stack" line was missing from the dump. (cherry picked from commit 1ecfd5a) Squashed from: 5f02345, cd929f0
With --safe-crash-log-file set, every jl_safe_printf to stderr calls jl_inside_signal_handler, which read jl_current_task->ptls. On threads with no current task, such as the unmanaged signal listener that prints on SIGUSR1/SIGINFO, that is a NULL dereference. (cherry picked from commit ca83149)
jl_fprint_bt_entry_codeloc built sig_str but only copied it into pre_str together with the thread ID, so backtraces printed from the signal listener thread lost the "signal (N) " prefix. (cherry picked from commit a2ca1b8)
jl_task_wait_empty (used by jl_write_compiler_output with --output-*) puts thread 0 to sleep until n_threads_running is 0. The heartbeat thread decremented the count after jl_adopt_thread without a wake-up, so a short process could hang at exit. (cherry picked from commit e050c51)
…uliaLang#63608) jl_idset_put_key` located the slot for a new key by walking backwards from the end of the key list over every free slot. The list grows by 50%, so each insert scanned a sizable fraction of the list and filling a set cost quadratic time: inserting 100k keys took about 0.5 s and 1M keys 42 s. Gallop back from the end until a used slot is found, then bisect that span for a free slot. Any free slot whose predecessor is used is valid, so holes left by `jl_idset_pop` are reused rather than skipped, and the compaction path when the last slot is used is unchanged. Benchmark: ``` function raw_insert(n) keys = Memory{Any}(undef, 0); idxs = Memory{Any}(undef, 0); idx = Ref{Int}(0) vals = [string("key-", i) for i in 1:n] GC.gc() @Elapsed for v in vals keys = ccall(:jl_idset_put_key, Any, (Any, Any, Ptr{Int}), keys, v, idx)::Memory{Any} idxs = ccall(:jl_idset_put_idx, Any, (Any, Any, Int), keys, idxs, idx[])::Memory end end function global_roots(n) vals = [string("root-", i) for i in 1:n] GC.gc() @Elapsed for v in vals ccall(:jl_as_global_root, Any, (Any, Cint), v, 1) end end ``` (cherry picked from commit 84cce6c) (cherry picked from commit b2f5705)
Backport of JuliaLang#62733 (c2c3174) to 1.13. Missing-method backedges are stored as typename => (signature => callers), so adding an edge is a hash lookup instead of a scan over every edge recorded for the type name. Invalidation intersects each signature once. The scan was quadratic and dominated loading large package images. Adapted to 1.13: jl_gc_wb instead of jl_gc_write, no SATB deletion barriers. The sysimage serializes the new structure; package images still drop these backedges. Squashed from: 3c0d1b5, 2e9b876
…fill `smallintset` and the `IdDict` tables (`iddict.c`) stopped a lookup after a size-dependent `max_probe` and grew a table only when an insert overflowed that same bound. A table could therefore sit nearly full: the top-level method-cache hash ran at 82% load, with probe sequences up to 101 long, and where a function landed in it moved its slow-path dispatch by up to 75 ns. At a million keys, a missing key in an `IdDict` or `IdSet` cost 1 to 3.7 µs. Now a lookup scans to the first empty slot. Since a pop leaves a tombstone and no slot is ever emptied again, every key is still found before it. An insert that has probed more than 8 slots grows the table instead, but only once it is at least half full (estimated from the dense index in `smallintset`, and from 64 evenly spaced slots in `iddict.c`), so that keys sharing a hash cannot grow a sparse table without bound. Growth is always 2x, which keeps a table at least a quarter full. Since nothing else empties a tombstone, a long probe that crossed one in a table under half full rehashes it at the same size instead, which drops them: otherwise a table that churns at a steady size would lose its empty slots one by one, until every miss scanned the whole table (an `IdSet` index churned two million times took 6.7 µs per miss, and now takes 37 ns). Missing-key lookups at a million keys now take 37 to 82 ns, and filling a 10k-key container from empty costs about 15 to 35 ns more per insert. Assisted-by: Claude Code (Opus 5.5) (cherry picked from commit cca4c76) (cherry picked from commit 367bb12)
…aLang#63940)" This reverts commit a9f64ed. (cherry picked from commit 5f8151b)
sroa_mutables! decides a mutable allocation doesn't escape when used_ssas[def] + sum(used_ssas[intermediaries]) - length(intermediaries) equals the number of getfield/setfield! uses it recorded. When DCE has already deleted an intermediary (e.g. the `π` in front of a dead `getfield`), that intermediary's use of the allocation is already gone from used_ssas[def], so subtracting it again cancels out a real escape. This miscompiles captured, reassigned locals whose final value is unused after inlining: the `Core.Box` stays, but SROA deletes the initializing `setfield!`, so the closure throws `UndefVarError` on first read. (cherry picked from commit bcb6e46)
lift_apply_args! (JuliaLang#59548) rewrites each tuple argument of a remaining Core._apply_iterate call into Core.svec(getfield(t, 1), ..., getfield(t, n)). A call only remains when the inliner did not unroll it, which for tuples means more than max_tuple_splat (32) elements. Expanding those costs n statements per call, so recursion over Base.tail became quadratic in the tuple length: compiling a recursive function over a 258-element tuple went from 0.3s on 1.10 to minutes. Only expand tuples of up to 32 elements, and pass longer ones through unchanged as 1.10 did. (cherry picked from commit 97324ba)
add_codeinsts_to_jit! added the requested code to the JIT first and then each callee, running inference in between for callees whose source was not kept. A second thread that needs the caller in that window completes it at once (prepare_compile), and every callee not yet in the JIT is then called through a specsig-to-fptr1 stub that boxes its arguments. The stub is never replaced. Resolve all sources first, then add everything, callees first. (cherry picked from commit 45d6df3)
A type cache grew only when an insert needed more than size/64 probes, so a large cache filled to about 95% first. Caches saved in images are trimmed to the smallest size that fits, so a process starts close to that point and tuple type lookups walk runs of hundreds of entries. The limit is now at most 64. Types with equal hashes can form a longer run than that, so lookups probe until an empty slot, inserts place a type past the limit while the table is less than half full, and rehashing keeps tables at most half full. Squashed from: a70a2ff, 98d7c6a
Signatures with a Union or a free type variable have no cached hash, so a method's specializations of that kind were found by a linear scan with jl_types_equal. Restoring package images inserts many of them into the same methods (getproperty, setproperty!, convert, ...), which made the restore quadratic. They are now indexed in speckeyset too. The key is the cached hash of the signature, or the hash the type cache computes for a type without one (jl_type_hash_nofail). These signatures are stored from the back of the array, and the key set is rebuilt when the array grows. The array is rooted during the lookup, since comparing types can reach a safepoint. smallintset sizes its element type for the value being inserted, since the first value in an empty set can now be larger than 255. Squashed from: 5dea9c2, 0192158, 656dd00, 4e43152 (gf.c, jltypes.c and julia_internal.h part)
The index was cleared and rebuilt after the array grew, so lock-free lookups could miss existing entries. Every entry is now stored from the front and never moves, so the index stays valid for every version of the array and is only appended to, after the entry is stored. Lookups load the array before the index. Singleton promotion indexes the existing entry before publishing the array. A new entry is stored with release, so its initialization is ordered before readers see it. jl_prune_idset leaves a method's shared empty keyset alone when it is not part of the image being written. Equal signatures written differently can still get different keys and then different MethodInstances, as in stock Julia. The intermediate designs that scanned to keep them together are not included: they made rai-server startup on 2 CPUs take 104 s instead of 9 s. Squashed from: f93d043, 4c16322, 2504992, f8ff0fb, e8906b2, efffb25, b7bbbc0, 642358a (without their processor.h version bumps)
The new layout of Method.specializations is not compatible with older images. The native image header takes its version from the new JL_IMAGE_FORMAT_VERSION, which is 4 now, instead of a literal 1. A raw .ji sysimage has no native header, so the check in parse_sysimg does not reach it. The serialized sysimage data now starts with a tag that holds the version, and loading exits when it does not match. Versions 2 and 3 belonged to intermediate layouts on the old branch. The comment in processor.h still lists them. Squashed from: 4d415a1, 05cd6a1, and the processor.h version bumps of f8ff0fb and b7bbbc0
Many code instances of one image, and of the images loaded after it, have edges with the same call signature. verify_call ran _methods_by_ftype for each of them. The result is now cached by signature for as long as the world counter does not change. The cache is checked on every use and is skipped while invalidation logging is on. A cache that was saved into a system image is dropped on its first use in a process (jl_reinfer_cache_first_use). empty_verify_call_cache! frees it. Squashed from: abba19b, a06353c, 4e43152 (reinfer.jl and jl_reinfer_cache_first_use part)
Experimental. Lets the heap grow by the given size per thread that allocated since the last collection, if that is more than the heuristic allows. The thread count is weighted by each thread's share of the allocated bytes. Also read from JULIA_HEAP_TARGET_INCREMENT_PER_THREAD; an invalid environment value prints a warning and leaves it off. The growth is capped at 1/16 of the memory limit and never raises the target above the --heap-size-hint limit. It is off with --hard-heap-limit or --heap-target-increment. Squashed from: 5e1476b, 33b3bfa
Their destructors take the lock of each module's context. At exit the other threads are suspended at a safepoint, possibly while compiling with such a lock held, and the static destructor of emittedmodules then waited for it forever. (cherry picked from commit 74abed2)
After jl_atexit_hook other threads may still run code in GC-safe regions (compiling) or be parked at a safepoint holding locks. Running static destructors and library finalizers next to them deadlocked or corrupted the heap at exit. Flush stdio and _exit instead, also when main returns, so jl_repl_entrypoint no longer returns. This skips LLVM -time-passes/-stats destructor output, the jitdump close, gcov/profile-runtime dumps and third-party libc atexit handlers. Julia's own exit work (atexit hooks, finalizers, coverage, stdio) stays in jl_atexit_hook. (cherry picked from commit 90717a8)
libuv 1.48 sends fs requests with a callback through an SQPOLL io_uring. uv__iou_submit stores the SQ tail and then reads IORING_SQ_NEED_WAKEUP without a full barrier, so when the SQ thread goes idle at that moment neither side sees the other and the request is never submitted. This hung the RAI_PagerCore tests, and a stress test of uv_fs_write reproduces it. Setting UV_USE_IO_URING=0 before the first loop is created keeps fs requests on the thread pool, as with libuv 1.44 in Julia 1.10. An explicit UV_USE_IO_URING still wins, so UV_USE_IO_URING=1 brings the bug back. libuv 1.49 made SQPOLL opt-in (libuv#4492). (cherry picked from commit 51dcdf5)
rbvermaa
marked this pull request as draft
November 23, 2026 08:44
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.
This is
rv-v1.13.4-port-fixes(51dcdf5779, the Julia that RAICode pins) rewritten into 32 commits in 8 groups. The old branch had 52 commits with experiments, fixups and reverts.The final tree is identical to
51dcdf5779. Check withgit diff --quiet 51dcdf5779 HEAD(both trees are8f4d35aab0). No code was edited by hand. Each commit is built from the original diffs.Review the groups in order. Groups 1 to 3 are the same stack as
v1.13.3+RAI. Groups 4 to 8 are new for the 1.13 upgrade."draft, not filed" means a write-up exists under
raicode-1.13/.work/experiments/upstream-*or injulia-issues.md, but no upstream issue or PR exists yet.1. Version
8277cc586b2. Ported RAI patch stack
Same patches as on
v1.12.6+RAI, in the same order.REPORT-patches.mdhas the reason for each.febeef8a7d859da72cdd0f27c337754a4d9e36f8b816b506d0320903eca8jl_print_task_backtraces()5f0234529e,cd929f0cee2a273fd986a7bb404285c6f1eac1ae55916bb170fd4209cdba5a29d8a8b5cd929f0ceerestored the "no stack" check that the first 1.13 port of5f0234529edropped. It is folded into that patch.3. Fixes to ported patches
c72d42a6b5bb243554eb728522ec07--output-*4. Upstream backports
06bfda9bedc98ad7853f3c0d1b5b7a,2e9b8765bcdab1a3400b703cc131443c0d1b5b7awas our own capped scan for the backedge problem.2e9b8765bcdeleted all of it and put the JuliaLang#62733 design in. The new commit is the combined effect, so the capped scan never appears.Why the revert: with JuliaLang#63940, rai-server
/statustakes 20.3 s instead of 10.2 s on 2 CPUs, and backedges after loading go from 12.2 M to 18.8 M. The revert keeps the 1.13.3 behaviour. It drops only the fix for JuliaLang#63933, which 1.13.3 also lacks.5. New compiler fixes
3214009a35julia-issues.md#1)ca873262b3julia-issues.md#2)f501898d5c6. New lookup and loading performance
83c72d3441a70a2ff92d,98d7c6a96002ae5484ecupstream-spec-index)5dea9c2d2e,0192158888,656dd000b0,4e43152aac(gf.c, jltypes.c, julia_internal.h part)b37372a473upstream-spec-index)f93d043e7c,4c16322643,25049921bf,f8ff0fb70f,e8906b25b5,efffb254d2,b7bbbc0b1b,642358a4b25c685d8bfb4d415a1f88,05cd6a1372, processor.h bumps off8ff0fb70fandb7bbbc0b1b7353f057a2abba19b53a,a06353cd2f,4e43152aac(reinfer.jl andjl_reinfer_cache_first_usepart)Notes for the reviewer:
02ae5484ecis the index and its key, as the old branch had it at4e43152aac.b37372a473is the net of everything after that: entries never move, the index is only appended to, and entries are published with release.JL_IMAGE_FORMAT_VERSIONinsrc/processor.hstill describes versions 2 and 3. Those were the intermediate designs. The tree had to stay identical, so the comment is unchanged. Clean it up in a follow-up.7. GC per-thread heap increment
1c37ab16635e1476bc2e,33b3bfabdf8. Exit and IO robustness
bcdc0e40cd55e78754d1666337d30dupstream-libuv-sqpoll); the libuv bug is libuv#5408, open fix in libuv#5409Dropped from the old branch
e5533eac314596d0522f; replaced by the JuliaLang#64962 backport8fc98f7449fa1d34dfccfa1d34dfcc8fc98f74494596d0522fe5533eac313c0d1b5b7ac98ad7853fOld SHA to new SHA
2ab02ae41ffebeef8a7d62ecfcae2e859da72cdd3f56873f490f27c337751ce6728bda4a4d9e36f8fc20bd73e6b816b506d05f0234529e320903eca80afa1db3e82a273fd986b551269138a7bb4042856b890353d1c6f1eac1ae16e7a595a355916bb1701cba5871b4fd4209cdba48b904b4dd5a29d8a8b5cd929f0cee320903eca8ca831496dbc72d42a6b5a2ca1b860fbb243554ebbcb6e464433214009a3597324baf4cca873262b33c0d1b5b7ac98ad7853f45d6df35f9f501898d5ca70a2ff92d83c72d34415dea9c2d2e02ae5484ec019215888802ae5484ec656dd000b002ae5484ecabba19b53a7353f057a2a06353cd2f7353f057a24e43152aac02ae5484ec,7353f057a25e1476bc2e1c37ab166333b3bfabdf1c37ab166398d7c6a96083c72d3441e050c5119f728522ec07b2f5705a6906bfda9bed2e9b8765bcc98ad7853f74abed2b0fbcdc0e40cd90717a86ce55e78754d1e5533eac318fc98f7449fa1d34dfcc4596d0522f367bb1260bdab1a3400bf93d043e7cb37372a4734c16322643b37372a4734d415a1f885c685d8bfb05cd6a13725c685d8bfb25049921bfb37372a473f8ff0fb70fb37372a473,5c685d8bfb5c685d8bfbe8906b25b5b37372a473efffb254d2b37372a473b7bbbc0b1bb37372a473,5c685d8bfb5c685d8bfb642358a4b2b37372a473785a3d2d048277cc586b5f8151b635703cc1314451dcdf5779666337d30ddab1a3400bnow comes before the specialization index. On the old branch it came after656dd000b0, which changed one argument of the samesmallintset_rehashcall. So indab1a3400bthat call still passes0, and02ae5484ecchanges it toval + 1as656dd000b0did.Not checked
The branch was not built or tested. The tree is byte-identical to
51dcdf5779, which is what RAICode CI runs. Intermediate commits were not compiled one by one.Checklist
rv-v1.13.4-port-fixesat51dcdf5779, which has the same tree as this branch).Not built or tested commit by commit: only the final tree is known good, because it equals the pinned one.
🤖 Generated with Claude Code