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

Stats for precompute tests #217

Open
JohnLCaron opened this issue Nov 17, 2022 · 3 comments
Open

Stats for precompute tests #217

JohnLCaron opened this issue Nov 17, 2022 · 3 comments

Comments

@JohnLCaron
Copy link
Collaborator

There are 25 contest/ballot and 4 selections per contest, giving 100 selections/ballot.
Single threaded on HP Z440 Workstation 6-core Intel Xeon E5-1650 v4 (3.6 GZ) Ubuntu 20.04, Java 17.

test 1. Precompute selections

  1. precompute all selections with vote = 0
  2. if user makes a selection, compute vote = 1 for that selection (retain vote = 0 encryption in case user changes their mind)
  3. when done, the contests and ballot are encrypted. latency is the time to do that
SelectionPrecomputeTest 100 selections/ballot

Test 0 revotes/ballot
          precompute: took 19122 msecs = 7.648 msecs/selection (2500 selections) = 764.88 msecs/ballot for 25 ballots
             revotes: took   0 msecs = .0 msecs/revote (0 revotes) = .0 msecs/ballot for 25 ballots
             latency: took 2779 msecs = 111.1 msecs/ballot (25 ballots) = 2779.0 msecs/ for 1 s
               total: took 21901 msecs = 8.760 msecs/selection (2500 selections) = 876.04 msecs/ballot for 25 ballots

Test 20 revotes/ballot
          precompute: took 18795 msecs = 7.518 msecs/selection (2500 selections) = 751.8 msecs/ballot for 25 ballots
             revotes: took 1995 msecs = 3.99 msecs/revote (500 revotes) = 79.8 msecs/ballot for 25 ballots
             latency: took 2614 msecs = 104.5 msecs/ballot (25 ballots) = 2614.0 msecs/ for 1 s
               total: took 23404 msecs = 9.361 msecs/selection (2500 selections) = 936.16 msecs/ballot for 25 ballots

Test 40 revotes/ballot
          precompute: took 18883 msecs = 7.553 msecs/selection (2500 selections) = 755.32 msecs/ballot for 25 ballots
             revotes: took 2464 msecs = 2.464 msecs/revote (1000 revotes) = 98.56 msecs/ballot for 25 ballots
             latency: took 2721 msecs = 108.8 msecs/ballot (25 ballots) = 2721.0 msecs/ for 1 s
               total: took 24068 msecs = 9.627 msecs/selection (2500 selections) = 962.72 msecs/ballot for 25 ballots

Test 60 revotes/ballot
          precompute: took 18736 msecs = 7.494 msecs/selection (2500 selections) = 749.44 msecs/ballot for 25 ballots
             revotes: took 2477 msecs = 1.651 msecs/revote (1500 revotes) = 99.08 msecs/ballot for 25 ballots
             latency: took 2648 msecs = 105.9 msecs/ballot (25 ballots) = 2648.0 msecs/ for 1 s
               total: took 23861 msecs = 9.544 msecs/selection (2500 selections) = 954.44 msecs/ballot for 25 ballots

results:

  1. precompute takes ~7.5 msec per selection, ~.75 seconds per ballot with 100 selections
  2. a vote triggering a selection encryption takes ~ 4 msec
  3. latency is ~100 msecs/ballot
  4. total CPU time is ~bounded by ~10 msec/selection, 1 sec / ballot with 100 selections, no matter how many revotes

test 2. Precompute Contests

  1. precompute all contests with first selection chosen (maybe makes more sense to have "none" selected?)
  2. if user makes a selection, compute new Contest encryption (not retaining previous result)
  3. when done, the ballot is encrypted. latency is the time to do that
ContestPrecomputeTest 100 selections/ballot

Test 0 revotes/ballot
          precompute: took 19108 msecs = 7.643 msecs/selection (2500 selections) = 764.32 msecs/ballot for 25 ballots
             revotes: took   0 msecs = .0 msecs/revote (0 revotes) = .0 msecs/ballot for 25 ballots
             latency: took   2 msecs = .08 msecs/ballot (25 ballots) = 2.0 msecs/ for 1 s
               total: took 19110 msecs = 7.644 msecs/selection (2500 selections) = 764.4 msecs/ballot for 25 ballots

Test 20 revotes/ballot
          precompute: took 18861 msecs = 7.544 msecs/selection (2500 selections) = 754.44 msecs/ballot for 25 ballots
             revotes: took 12036 msecs = 24.07 msecs/revote (500 revotes) = 481.44 msecs/ballot for 25 ballots
             latency: took   0 msecs = .0 msecs/ballot (25 ballots) = .0 msecs/ for 1 s
               total: took 30897 msecs = 12.35 msecs/selection (2500 selections) = 1235.8 msecs/ballot for 25 ballots

Test 40 revotes/ballot
          precompute: took 18745 msecs = 7.498 msecs/selection (2500 selections) = 749.8 msecs/ballot for 25 ballots
             revotes: took 23699 msecs = 23.69 msecs/revote (1000 revotes) = 947.96 msecs/ballot for 25 ballots
             latency: took   0 msecs = .0 msecs/ballot (25 ballots) = .0 msecs/ for 1 s
               total: took 42444 msecs = 16.97 msecs/selection (2500 selections) = 1697.7 msecs/ballot for 25 ballots

Test 60 revotes/ballot
          precompute: took 19608 msecs = 7.843 msecs/selection (2500 selections) = 784.32 msecs/ballot for 25 ballots
             revotes: took 36926 msecs = 24.61 msecs/revote (1500 revotes) = 1477.0 msecs/ballot for 25 ballots
             latency: took   1 msecs = .04 msecs/ballot (25 ballots) = 1.0 msecs/ for 1 s
               total: took 56535 msecs = 22.61 msecs/selection (2500 selections) = 2261.4 msecs/ballot for 25 ballots
               

results:

  1. precompute takes ~7.5 msec per selection, ~.75 seconds per ballot with 100 selections
  2. a vote triggering a contest reencryption takes ~ 25 msec
  3. latency is > 1 msec/ballot
  4. total CPU time irises by the number of revotes - probably could fix that

Code is in ContestPrecomputeTest and SelectionPrecomputeTest.
Its prototype code for timing, probably has some bugs. But the encrypted ballots verify, so its not too far off.

@JohnLCaron
Copy link
Collaborator Author

We need to know 1) the timings on target hardware, and 2) the required maximum latency of voting. Latency here means the lag between voter pressing "im done with this ballot" and the system finishing the encryption and producing the confirmation code.

Precompute requires coupling the encryption library and the UI. Could build an encryption webapp to prototype the communication.

@JohnLCaron
Copy link
Collaborator Author

These prototypes assume that the ballotId and ballotStyleId and the codeSeed are all available at the start of the precomputation. That is, that precomputation starts when the voter is given a ballot to start filling out. Precomputation overlaps the process of filling out the ballot, ie overlaps the UI processing.

One could also try caching preencrypted ballots, assuming theres only a few common ballotStyles in use, and that the ballot id and code seed can be generated in advance.

Until we know the characteristics of the target system, this may be premature optimization.

@JohnLCaron
Copy link
Collaborator Author

This is not pre-encryption, rather this is some prototypes to reduce latency when encrypting on a BMD. The user is waiting for the confirmation code from the encryption.

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

No branches or pull requests

1 participant