Common list operations exhibit O(n^2) time complexity

Open
#1,953 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, erlang

Research direction

The issue reports quadratic behavior in lists:seq/3, lists:flatten/1 and lists:join/2, and suggests either adding NIFs or changing garbage collection. Start by reading these list operations and the garbage collector implementation, then profile the reported cases to locate the cause. Done means the affected operations scale linearly and have tests or benchmarks demonstrating the improvement.

Written by the indexing model from the issue text.

Description

Probably because of aggressive gc implementation, common list operations exhibit a quadratic time complexity.
This was observed with lists:seq/3, lists:flatten/1 and lists:join/2.

We could replace them with nifs that compute size to allocate only once, or fix GC.

Dominant language
Erlang
Stars
2.3k
Forks
171
Avg merge
4d 11h
Merged PRs (30d)
20

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 atomvm/AtomVM

All issues in atomvm/AtomVM

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.