Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a sublist primop #2459

Closed
wants to merge 1 commit into from
Closed

Conversation

cleverca22
Copy link
Contributor

@cleverca22 cleverca22 commented Sep 30, 2018

for one of the expressions ive been optimizing, it reduces:
calls to elemAt from 108 million to 59 thousand
adds 106k calls to builtins.sublist
values created down from 400m to 5m
total eval time down from 149sec to 15sec

for a related expression in the same set, it reduces the eval time from 45 minutes to 2 minutes, while still producing the same .drv path at the end

a 3rd related expression took over 147 minutes and 66gig of ram (and never finished, i had to kill it)
after this change, it took 19 minutes

for one of the expressions ive been optimizing, it reduces:
calls to elemAt from 108 million to 59 thousand
adds 106k calls to builtins.sublist
values created down from 400m to 5m
total eval time down from 149sec to 15sec
@disassembler
Copy link
Member

LGTM! 👍

int start = state.forceInt(*args[0], pos);
size_t len = state.forceInt(*args[1], pos);
state.forceList(*args[2], pos);
size_t count = std::min(args[2]->listSize() - start, len);
Copy link
Member

Choose a reason for hiding this comment

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

I think this underflows if start > listSize().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can confirm it malfunctions:

nix-repl> builtins.sublist 11 3 [ 1 2 3 4 5 6 7 8 9 10 ]
start is 11
len is 3
listSize is 10
count is 3
[ Segmentation fault (core dumped)

will update the PR soon

@grahamc
Copy link
Member

grahamc commented Oct 2, 2018 via email

@dtzWill
Copy link
Member

dtzWill commented Oct 29, 2018

Friendly ping! No rush on my account, just want to help ensure doesn't fall through the cracks :).

@stale
Copy link

stale bot commented Feb 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 13, 2021
@cleverca22
Copy link
Contributor Author

still need to get around to this, not completely stale

@stale stale bot removed the stale label Feb 14, 2021
@stale
Copy link

stale bot commented Aug 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Aug 13, 2021
@fricklerhandwerk fricklerhandwerk added feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc performance labels Mar 3, 2023
@stale stale bot removed stale labels Mar 3, 2023
@Ericson2314 Ericson2314 marked this pull request as draft March 10, 2023 21:51
@Ericson2314
Copy link
Member

Ericson2314 commented Mar 10, 2023

Marked as draft because:

  1. Needs tests
  2. Needs fixed behavior with out-of-bound indices

I think the idea is good, however. @cleverca22's numbers at the top are, well, shocking! And we have builtins.substring so this matches. I cannot unilaterally add the label without the rest of the team's input, however.

@thufschmitt thufschmitt self-assigned this Apr 28, 2023
@fricklerhandwerk
Copy link
Contributor

Triaged in Nix team meeting:

  • @edolstra: wonder if we could be lazy, essentially implementing slices
    • @thufschmitt: thought that, too, but can't promise this will end up in the implementation
  • idea approved, @thufschmitt will take over

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-04-28-nix-team-meeting-minutes-50/27698/1

@balsoft balsoft mentioned this pull request May 4, 2023
8 tasks
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tweag-nix-dev-update-48/28102/1

@thufschmitt
Copy link
Member

Closing since #8290 took over (and is also closed by lack of evidence of the performance gain).
@cleverca22 , feel free to reopen if you want to work on this again

@thufschmitt thufschmitt closed this Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc performance
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

9 participants