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

Alloc genotype memory from mmap #808

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Conversation

jeromekelleher
Copy link
Member

Here's a quick stab that should basically work; fancy trying it out @benjeffery?

@jeromekelleher jeromekelleher marked this pull request as draft March 3, 2023 17:17
@benjeffery
Copy link
Member

benjeffery commented Mar 3, 2023

Speedy! My only option on the cluster at the moment is to try this out on an network drive. I will also do the same thing on my machine, using an NMVe drive with the same ram/disk ratio to get a feel for if the performance is viable and how much the network impacts that.

@jeromekelleher
Copy link
Member Author

Top level interface for Python is mmap_temp_dir.

@benjeffery
Copy link
Member

benjeffery commented Mar 7, 2023

Some performance numbers:

run time page faults
main 8m11s 2974
mmap, 100%RAM, NMVe 8m10s 2613
mmap, 50%RAM, NMVe 8m48s 199121
mmap, 50%RAM, magnetic 1hr39min 1080637

I'm not sure why the magnetic run had so many more page faults. Will do some more testing after it's easier to set the mmap location.

@hyanwong
Copy link
Member

hyanwong commented Mar 7, 2023

That's looking feasible, right. What is the non-mmap time?

@benjeffery
Copy link
Member

That's looking feasible, right. What is the non-mmap time?

First line of the table - 8:11.

@hyanwong
Copy link
Member

hyanwong commented Mar 7, 2023

That's looking feasible, right. What is the non-mmap time?

First line of the table - 8:11.

Oops. Didn't realise. Doh! Thanks 🤦

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #808 (bc1db15) into main (2b6e898) will decrease coverage by 0.30%.
The diff coverage is 89.61%.

❗ Current head bc1db15 differs from pull request most recent head 0437b60. Consider uploading reports for the commit 0437b60 to get more accurate results

@@            Coverage Diff             @@
##             main     #808      +/-   ##
==========================================
- Coverage   93.50%   93.21%   -0.30%     
==========================================
  Files          17       17              
  Lines        5821     5835      +14     
  Branches     1041     1044       +3     
==========================================
- Hits         5443     5439       -4     
- Misses        248      265      +17     
- Partials      130      131       +1     
Flag Coverage Δ
C 93.21% <89.61%> (-0.30%) ⬇️
python 95.90% <79.12%> (-0.46%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tsinfer/formats.py 96.28% <9.52%> (-1.22%) ⬇️
lib/ancestor_builder.c 90.56% <95.18%> (+0.64%) ⬆️
lib/err.c 100.00% <100.00%> (ø)
tsinfer/algorithm.py 98.55% <100.00%> (ø)
tsinfer/constants.py 100.00% <100.00%> (ø)
tsinfer/inference.py 98.57% <100.00%> (-0.11%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jeromekelleher
Copy link
Member Author

This is ready for review - stacked on #808

@jeromekelleher jeromekelleher marked this pull request as ready for review April 3, 2023 15:46
@benjeffery
Copy link
Member

I'll take a look at this once #808 is in and the diff is easy to review.

@jeromekelleher
Copy link
Member Author

Updated

Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

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

Awesome, just a couple of comments.

goto out;
}
self->mmap_buffer = mmap(
NULL, self->mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, self->mmap_fd, 0);
Copy link
Member

Choose a reason for hiding this comment

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

This is probably unnecessary complexity, but once the genotypes are loaded into the mmap, we could speed things up by re-opening it with only PROT_READ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I think the benefit would be marginal, and it might cause a full flush of the file.

Worth following up if you like though, we can open an issue?

)
a1.assert_data_equal(a2)

def test_mmap_missing_dir(self):
Copy link
Member

Choose a reason for hiding this comment

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

Test mmap to dir with the wrong perms to check we get a nice message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

tsinfer/inference.py Outdated Show resolved Hide resolved
num_threads=num_threads,
mmap_temp_dir=tmpdir,
)
a1.assert_data_equal(a2)
Copy link
Member

Choose a reason for hiding this comment

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

Can we also test that mmap file has been removed after generating the ancestors?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, done

@jeromekelleher
Copy link
Member Author

Comments addressed, should be ready to go

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.

None yet

3 participants