Ambyte cost: size proven slices by their length and share literals instead of copying them

Open
#433 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start by reading issue #430 and the Baker Street finding F1 on #432, then trace Core typing for slice and the constant rule to identify what the Echo lowerer and verifier can read. Coordinate the spec, compiler, and Echo judge changes with a component promotion. Done means the two charges stay the same at bounds 32 and 4,352, judges accept the compiler minimum and reject one step or byte below it, and ReplaceRange's before and after costs are recorded.

Written by the indexing model from the issue text.

Description

enhancement release:target-ir
.dag: issue-dag/2
.id: ambyte-lang/ambyte#433
.kind: task
.type: feature
.blocks: [flyingrobots/jim#5]
.after: [flyingrobots/amblicit#430]
.size_hours: 10

Outcome

Under edict.core-cost/v2, two allocation charges stop scaling with declared maxima that the program never reaches:

  1. A slice(b, s, e) whose length e - s is proven (constant bounds, or bounds that differ by a constant) produces a result sized at that length, not at b's bound, in steps and in allocation.
  2. A text or byte literal is shared from the package, like other shared values: it is charged its reference (one cell), not a full copy each time it is evaluated.

Why

This is the attribution on #430, for ReplaceRange on jedit#410 at 9e5863d (173,660,515 allocated bytes in total):

  • literals copied in full account for about 49.2M;
  • slice results for about 8.9M.

After #430, slice still charges its result at the operand's bound (Baker Street finding F1 on #432).

Scope

  • Core typing of the slice result, or a proven-length side fact, that Echo's lowerer and verifier can read. The spec, the compiler and every Echo judge change together, with a component promotion.
  • The constant rule, in the same way.

Test Plan

  • RED: the static charge of slice(b, 0, 4) grows with b's bound, and a fold that reads b"abcd" 100 times allocates the literal 100 times.
  • GREEN: both are the same at bounds 32 and 4,352. Echo's judges admit at exactly the compiler minimum and refuse one step or byte below it.
  • Record ReplaceRange's static steps and bytes before and after.
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flyingrobots/edict

All issues in flyingrobots/edict

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.