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

Adds PrivateNearestNeighbhorsSearch Client #72

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

fboemer
Copy link
Contributor

@fboemer fboemer commented Aug 23, 2024

Adds PrivateNearestNeighbhorsSearch Client, with a few changes along the way:

  • Allow constant-time CRT composition when the composed modulus fits in a ScalarType, by:

    1. Creating a separate crtComposer (a more limited API than the messier RnsTool) . For now, it's package, but I figure we could make it public eventually.
    2. Generalizing some Scalar ops from ScalarType to FixedWidthInteger & UnsignedInteger
  • Reordered crtCompose loops -> ~2x speedup in NoiseBudget benchmarks.
    Before


NoiseBudget Bfv<UInt32>
╒═══════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│ Metric                        │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞═══════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│ Malloc (total) *              │    8209 │    8209 │    8209 │    8209 │    8209 │    8209 │    8209 │    3270 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Memory (resident peak) (M)    │      17 │      18 │      18 │      18 │      18 │      18 │      18 │    3270 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Time (wall clock) (μs) *      │     841 │     860 │     863 │     872 │     883 │     941 │    1066 │    3270 │
╘═══════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

NoiseBudget Bfv<UInt64>
╒═══════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│ Metric                        │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞═══════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│ Malloc (total) *              │    8211 │    8211 │    8211 │    8211 │    8211 │    8211 │    8211 │    2703 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Memory (resident peak) (M)    │      24 │      25 │      25 │      25 │      25 │      25 │      25 │    2703 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Time (wall clock) (μs) *      │    1016 │    1040 │    1047 │    1065 │    1100 │    1176 │    1472 │    2703 │
╘═══════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

After

NoiseBudget Bfv<UInt32>
╒═══════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│ Metric                        │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞═══════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│ Malloc (total) *              │      17 │      17 │      17 │      17 │      17 │      17 │      17 │    9737 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Memory (resident peak) (M)    │      18 │      18 │      18 │      18 │      18 │      18 │      18 │    9737 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Time (wall clock) (μs) *      │     248 │     253 │     254 │     260 │     270 │     313 │    7228 │    9737 │
╘═══════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

NoiseBudget Bfv<UInt64>
╒═══════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│ Metric                        │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞═══════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│ Malloc (total) *              │      19 │      19 │      19 │      19 │      19 │      19 │      19 │    5498 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Memory (resident peak) (M)    │      24 │      25 │      25 │      25 │      25 │      25 │      25 │    5498 │
├───────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Time (wall clock) (μs) *      │     486 │     490 │     498 │     501 │     506 │     531 │     674 │    5498 │
╘═══════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

@fboemer fboemer merged commit 9e1e876 into main Aug 23, 2024
6 checks passed
@fboemer fboemer deleted the fboemer/pnns-client-server branch August 23, 2024 00:57
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.

2 participants