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

Refactor API + Implement Chunking + Ring Backend Support #11

Merged
merged 30 commits into from
Mar 31, 2022
Merged

Conversation

landhb
Copy link
Owner

@landhb landhb commented Mar 29, 2022

Large re-design of the exposed API while trying to minimize performance/protocol changes.

  • The portal-lib crate will be split into a higher-level API and a lower-level API exposed via crate::protocol.

A higher level file send will look like:

let portal = Portal::init(Direction::Sender, id, password)?;

// conduct the handshake with the peer
portal.handshake(&mut stream)?;

// Optional: implement a custom callback to display how much
// has been transferred
fn progress(transferred: usize) {
    println!("sent {:?} bytes", transferred);
}

portal.send_file(&mut stream, "/etc/passwd", Some(progress));

A higher level file recv will look like:

let portal = Portal::init(Direction::Receiver, id, password)?;

// conduct the handshake with the peer
portal.handshake(&mut stream)?;

// Optional: User callback to confirm/deny a transfer. If
// none is provided, this will default accept the incoming file.
// Return true to accept, false to reject the transfer.
fn confirm_download(path: &str, size: u64) -> bool { true }

// Optional: implement a custom callback to display how much
// has been transferred
fn progress(transferred: usize) {
    println!("sent {:?} bytes", transferred);
}

portal.recv_file(&mut client, Path::new("/tmp"), Some(confirm_download), Some(progress));

@landhb landhb self-assigned this Mar 29, 2022
@landhb landhb added the refactor Refactor label Mar 29, 2022
@github-actions
Copy link

Benchmark for 36fa8fb

Click to view benchmark
Test Base PR %
encrypt & send 100k 496.8±30.55µs 282.5±14.62µs -43.14%
encrypt & send 1M 4.3±0.15ms 2.5±0.07ms -41.86%
larger-files/encrypt & send 100M 440.3±4.31ms 261.8±4.09ms -40.54%
larger-files/encrypt & send 500M 2.2±0.02s 1272.4±15.39ms -42.16%
larger-files/receive & decrypt 100M 815.4±7.21ms 1098.1±14.42ms +34.67%
larger-files/receive & decrypt 500M 4.8±0.29s 6.3±0.19s +31.25%
receive & decrypt 100k 564.8±14.87µs 548.6±21.22µs -2.87%
receive & decrypt 1M 5.8±0.23ms 6.0±0.23ms +3.45%

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2022

Codecov Report

Merging #11 (329042d) into master (77333fc) will increase coverage by 1.36%.
The diff coverage is 92.63%.

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
+ Coverage   91.96%   93.33%   +1.36%     
==========================================
  Files           4        4              
  Lines         448      210     -238     
==========================================
- Hits          412      196     -216     
+ Misses         36       14      -22     
Impacted Files Coverage Δ
lib/src/protocol/exchange.rs 81.81% <81.81%> (ø)
lib/src/lib.rs 94.04% <92.18%> (+0.52%) ⬆️
lib/src/protocol/mod.rs 95.38% <95.38%> (ø)
lib/src/protocol/encrypted.rs 100.00% <100.00%> (ø)
client/src/main.rs

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77333fc...329042d. Read the comment docs.

@github-actions
Copy link

Benchmark for 6cec841

Click to view benchmark
Test Base PR %
encrypt & send 100k 315.1±0.51µs 199.6±0.43µs -36.66%
encrypt & send 1M 3.1±0.00ms 1838.1±18.37µs -40.71%
larger-files/encrypt & send 100M 324.8±0.11ms 207.1±0.87ms -36.24%
larger-files/encrypt & send 500M 1635.0±0.87ms 1036.0±1.39ms -36.64%
larger-files/receive & decrypt 100M 568.5±1.68ms 672.0±8.50ms +18.21%
larger-files/receive & decrypt 500M 3.6±0.15s 4.7±0.27s +30.56%
receive & decrypt 100k 338.3±0.34µs 295.3±0.30µs -12.71%
receive & decrypt 1M 3.6±0.08ms 3.0±0.00ms -16.67%

@github-actions
Copy link

Benchmark for 3547e5f

Click to view benchmark
Test Base PR %
encrypt & send 100k 283.2±0.33µs 182.7±0.46µs -35.49%
encrypt & send 1M 2.7±0.01ms 1689.6±3.99µs -37.42%
larger-files/encrypt & send 100M 292.1±0.17ms 188.6±0.22ms -35.43%
larger-files/encrypt & send 500M 1449.0±0.89ms N/A N/A
larger-files/receive & decrypt 100M 505.3±12.09ms 188.1±1.46s +37125.41%
larger-files/receive & decrypt 500M 3.2±0.25s N/A N/A
receive & decrypt 100k 339.0±3.67µs 314.6±0.98µs -7.20%
receive & decrypt 1M 3.1±0.02ms 6.8±0.05ms +119.35%

@landhb landhb changed the title Refactor API Refactor API + Implement Chunking + Ring Backend Support Mar 30, 2022
@github-actions
Copy link

Benchmark for 67d0649

Click to view benchmark
Test Base PR %
encrypt & send 100k 281.0±1.74µs 206.3±1.84µs -26.58%
encrypt & send 1M 2.7±0.01ms 1677.0±28.67µs -37.89%
larger-files/encrypt & send 100M 290.6±0.30ms 185.7±0.51ms -36.10%
larger-files/encrypt & send 500M 1484.8±72.24ms 1030.2±4.77ms -30.62%
larger-files/receive & decrypt 100M 532.3±1.23ms 184.6±23.74ms -65.32%
larger-files/receive & decrypt 500M 3.6±0.22s 1095.2±284.11ms -69.58%
receive & decrypt 100k 297.8±1.31µs 181.3±3.56µs -39.12%
receive & decrypt 1M 3.1±0.01ms 1580.1±51.83µs -49.03%

@landhb landhb marked this pull request as ready for review March 31, 2022 00:03
@landhb landhb merged commit 6775feb into master Mar 31, 2022
@landhb landhb deleted the refactor branch March 31, 2022 00:09
@landhb landhb mentioned this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants