Files
Nim/lib/system
ringabout 854c1f15ba fixes #25687; optimizes seq assignment for orc (#25689)
fixes #25687

This pull request introduces an optimization for sequence (`seq`)
assignments and copies in the Nim compiler, enabling bulk memory copying
for sequences whose element types are trivially copyable (i.e., no GC
references or destructors). This can significantly improve performance
for such types by avoiding per-element loops.

Key changes:

### Compiler code generation improvements

* Added the `elemSupportsCopyMem` function in
`compiler/liftdestructors.nim` to detect if a sequence's element type is
trivially copyable (no GC refs, no destructors).
* Updated the `fillSeqOp` procedure to use a new `genBulkCopySeq` code
path for eligible element types, generating a call to
`nimCopySeqPayload` for efficient bulk copying. Fallback to the
element-wise loop remains for non-trivial types.
[[1]](diffhunk://#diff-456118dde9a4e21f1b351fd72504d62fc16e9c30354dbb9a3efcb95a29067863R665-R670)
[[2]](diffhunk://#diff-456118dde9a4e21f1b351fd72504d62fc16e9c30354dbb9a3efcb95a29067863R623-R655)

### Runtime support

* Introduced the `nimCopySeqPayload` procedure in
`lib/system/seqs_v2.nim`, which performs the actual bulk memory copy of
sequence data using `copyMem`. This is only used for types that are safe
for such an operation.

These changes collectively improve the efficiency of sequence operations
for simple types, while maintaining correctness for complex types.


### Benchmarked the original micro-benchmark:
refc: 3.52s user 0.02s system 99% cpu 3.538 total
orc (after change): 3.46s user 0.01s system 99% cpu 3.476 total

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-02 11:46:49 +02:00
..
2026-04-02 07:19:43 +02:00
2025-11-25 12:49:23 +01:00
2025-12-07 13:07:44 +01:00
2026-04-02 07:19:43 +02:00
2025-12-01 22:59:12 +01:00
2025-10-28 12:48:22 +01:00
2026-02-20 16:41:06 +01:00
2026-02-20 16:41:06 +01:00
2026-02-20 16:41:06 +01:00
2026-04-02 07:19:43 +02:00
2024-08-11 10:35:09 +08:00
2026-02-20 16:41:06 +01:00
2026-02-10 13:21:35 +01:00
2026-02-20 16:41:06 +01:00
2026-02-23 13:39:55 +01:00
2026-02-23 13:39:55 +01:00
2025-12-07 13:07:44 +01:00
2026-04-02 07:19:43 +02:00
2026-04-02 07:19:43 +02:00
2026-04-02 07:19:43 +02:00
2020-01-30 10:54:50 +01:00
2026-02-23 13:39:55 +01:00
2026-02-24 11:12:28 +01:00