Skip to content

Add get_key() builtin for table value-to-key lookup#2322

Merged
borisbat merged 2 commits into
masterfrom
perf-lint-moar
Mar 22, 2026
Merged

Add get_key() builtin for table value-to-key lookup#2322
borisbat merged 2 commits into
masterfrom
perf-lint-moar

Conversation

@borisbat
Copy link
Copy Markdown
Collaborator

@borisbat borisbat commented Mar 22, 2026

Summary

  • Add get_key(tab, value_ref) builtin that computes a table key from a value reference obtained during values() iteration — O(1) pointer arithmetic on the parallel key/value arrays
  • Robust validation: bounds check, alignment check, tombstone/deleted-slot check with proper error messages via Context/LineInfo
  • Install utils/perf_lint/ in CMake install targets
  • Fix perf_lint.rst exit code documentation (was "1 if warnings", actually "1 if compile errors")
  • Add benchmarks/core/table/ comparing get_key vs keys()+values() iteration
  • Add benchmarks/core/array/test02.das — push vs push_clone benchmark for int, struct, and large struct (10K elements, pre-reserved)
  • Reorganize benchmarks: rename array_lock/array/, table_key_value/table/
  • Add roadmap/optimizations.md with optimization notes on each_kv iterator and push vs push_clone
  • Replace 10 handmade doc stubs with proper descriptions (back, each, emplace, empty, find_index_if, get, insert_default, key_exists, lock, subarray)

Test plan

  • bin/Release/daslang.exe dastest/dastest.das -- --test tests/language/table_get_key.das — 12 tests (int/float, string/int, const table, tombstones, empty, single entry)
  • Error handling: passing a non-table value pointer correctly throws via try/recover
  • Benchmark compiles: dastest/dastest.das -- --test benchmarks/core/table/test01.das
  • Benchmark compiles: dastest/dastest.das -- --test benchmarks/core/array/test02.das
  • das2rst.das regenerated, no stubs remain, no Uncategorized sections
  • CI

borisbat and others added 2 commits March 22, 2026 08:07
Adds get_key(tab, value_ref) that computes the table key from a value
reference obtained during values() iteration via O(1) pointer arithmetic
on the parallel key/value arrays. Includes bounds, alignment, and
tombstone validation with proper error messages.

Also: install utils/perf_lint, fix perf_lint.rst exit code docs,
add table_key_value benchmark, add roadmap/optimizations.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add benchmarks/core/array/test02.das: push vs push_clone for int, struct, and large struct
- Replace 10 handmade doc stubs with proper descriptions (back, each, emplace, empty, find_index_if, get, insert_default, key_exists, lock, subarray)
- Rename array_lock/ -> array/, table_key_value/ -> table/ for cleaner benchmark organization
- Update benchmarks/README.md and roadmap/optimizations.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@borisbat borisbat merged commit e04396a into master Mar 22, 2026
24 checks passed
@borisbat borisbat deleted the perf-lint-moar branch March 25, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant