Files
Nim/compiler
ringabout d8f09f7604 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:

* 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)

* 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.

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>
(cherry picked from commit 854c1f15ba)
2026-04-03 12:47:11 +02:00
..
2023-12-15 10:20:57 +01:00
2026-01-09 09:03:51 +01:00
2025-11-27 19:03:50 +01:00
2025-01-14 07:53:29 +01:00
2026-03-17 10:12:06 +01:00
2026-01-09 09:03:51 +01:00
2017-01-07 22:35:09 +01:00
2026-01-09 09:03:51 +01:00
2026-03-09 10:13:31 +01:00
2025-01-15 10:21:20 +01:00
2026-01-09 09:03:51 +01:00
2021-01-12 09:36:51 +01:00
2024-07-09 09:29:45 +02:00
2026-01-09 09:03:51 +01:00
2025-01-14 07:51:55 +01:00
2023-07-02 22:36:05 +02:00
2023-11-06 18:33:28 +01:00
2025-09-22 08:47:23 +02:00
2024-03-16 08:35:18 +08:00
2023-12-25 07:12:54 +01:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.