[zeek/spicy] 174efd: Speed up checking of iterator compatibility.

0 views
Skip to first unread message

Benjamin Bannier

unread,
Jun 6, 2025, 5:39:17 AM6/6/25
to spicy-...@zeek.org
Branch: refs/heads/topic/bbannier/issue-1663
Home: https://github.com/zeek/spicy
Commit: 174efd18aa76a8469faf205e77795b92df60ac30
https://github.com/zeek/spicy/commit/174efd18aa76a8469faf205e77795b92df60ac30
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-06-06 (Fri, 06 Jun 2025)

Changed paths:
M hilti/runtime/include/types/bytes.h
M hilti/runtime/include/types/map.h
M hilti/runtime/include/types/set.h
M hilti/runtime/include/types/vector.h
M hilti/runtime/include/util.h
M hilti/runtime/src/tests/bytes.cc
M hilti/runtime/src/tests/map.cc
M hilti/runtime/src/tests/set.cc
M tests/Baseline/hilti.rt.exception-location/output

Log Message:
-----------
Speed up checking of iterator compatibility.

We were previously using a control block which held a weak_ptr to the
protected data. This was pretty inefficient for a number of reasons:

- access to the controlled data always required a `weak_ptr::lock` which
created a temporary shared_ptr copy and immediately destroyed it after
access
- to check whether the control block was expired we used `lock` instead
of `expired` which introduced the same overhead
- to check compatibility of iterators we compared shared_ptrs to the
control data which again required full locks instead of using
`owner_before`

This patch introduces a new control block data structure and uses it
across all classes which previously held ad hoc implementations
(`Bytes`, `Map`, `Set`, `Vector`). The main improvement is that we now
separate tracking liveliness and the data, and use a better
implementation for control block equality checks. With the new
implementation I see throughput improvements across the board for
anything needing to iterate, e.g., I see bytes iteration being up to 30x
faster in trivial setups; the code from the original issue is now 10x
faster.

Closes #1663.


Commit: 26904b7f0ea52ffa8bcff4fb0a19a524ab72b997
https://github.com/zeek/spicy/commit/26904b7f0ea52ffa8bcff4fb0a19a524ab72b997
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-06-06 (Fri, 06 Jun 2025)

Changed paths:
M .github/workflows/benchmark.yml
M hilti/CMakeLists.txt
M hilti/runtime/CMakeLists.txt
A hilti/runtime/src/benchmarks/iteration.cc

Log Message:
-----------
Add benchmark for iteration of rt containers.

This patch repurposes the existing `hilti-rt-fiber-benchmark` to be a
more general benchmark suite of HILTI runtime behaviors.


Commit: 05c99842de8a641f5d49b7549d5111c2767fe500
https://github.com/zeek/spicy/commit/05c99842de8a641f5d49b7549d5111c2767fe500
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-06-06 (Fri, 06 Jun 2025)

Changed paths:
M CMakeLists.txt

Log Message:
-----------
Make `-Warray-bounds` not fatal with gcc-13.0.

This diagnostic returns false positives in code we do not own and in
ways which are hard to work around with pragmas, see e.g.,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111273.


Commit: f5fc88971ac21172758de27b3183a141427233b5
https://github.com/zeek/spicy/commit/f5fc88971ac21172758de27b3183a141427233b5
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-06-06 (Fri, 06 Jun 2025)

Changed paths:
M ci/Dockerfile

Log Message:
-----------
Bump main CI image to ubuntu-24.04.


Commit: 993ca7824aa11d855e033cac8ee40c9a8b29b939
https://github.com/zeek/spicy/commit/993ca7824aa11d855e033cac8ee40c9a8b29b939
Author: Benjamin Bannier <benjamin...@corelight.com>
Date: 2025-06-06 (Fri, 06 Jun 2025)

Changed paths:
M spicy/toolchain/bin/spicy-dump/printer-json.cc

Log Message:
-----------
Fix `readability-qualified-auto` lint.


Compare: https://github.com/zeek/spicy/compare/07319d67f4ae...993ca7824aa1

To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications
Reply all
Reply to author
Forward
0 new messages