Skip to content

vlib.datatypes: optimize linkedlist - #23934

Merged
spytheman merged 1 commit into
vlang:masterfrom
kbkpbot:datatypes-linklist-opt
Mar 14, 2025
Merged

spytheman merged 1 commit into
vlang:masterfrom
kbkpbot:datatypes-linklist-opt

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Mar 14, 2025 •

Copy link
Copy Markdown
Contributor

Fix issue #23928

  1. add a field tail in LinkedList[T];
  2. use nil instead of 0, use isnil replace some unsafe blocks.
  3. add @[heap], @[inline]

list.v

module main

import datatypes
import benchmark

fn main() {
        mut b := benchmark.start()
        mut list := datatypes.LinkedList[int]{}

        for i in 0 .. 10_000_000 {
                list.push(i)
        }
        b.measure('list.push')
}
v -prod list.v
./list
 SPENT   777.296 ms in list.push

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22332

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman
spytheman merged commit e8c6922 into vlang:master Mar 14, 2025
@medvednikov

Copy link
Copy Markdown
Member

Thanks!

Just wondering, what was the old number?

v -prod list.v
./list
 SPENT   777.296 ms in list.push

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.

3 participants