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

Security Audit FPS-19 #1197

Closed
cryptonemo opened this issue Jul 2, 2020 · 1 comment · Fixed by #1198
Closed

Security Audit FPS-19 #1197

cryptonemo opened this issue Jul 2, 2020 · 1 comment · Fixed by #1198
Assignees

Comments

@cryptonemo
Copy link
Collaborator

Description

The function generate_labels() iterates though the layers of the Stacked DRG, creating labels for each node based off their parents in both this layer and the previous one.

The function stores an array of the labels consisting of the current layer and the previous layer as
labels_buffer of length n ∗ 2 where n is the size of a layer. The first n nodes (i.e. [0, n)) represent the current
layer and the second n (i.e. [n, 2n)) nodes represent the previous layer.

At the end of the iteration of each layer there is a memcopy of the current nodes to the previous nodes (i.e. the
first n nodes are copied over the second n nodes). Subsequently, the next iteration will overwrite the current
nodes (i.e. the first n nodes) with the new current layer nodes.

These new current layer nodes overwrite the first n nodes without reading them. Thus, the memcopy can be
avoided.

It can be avoided by, at the end of the first iteration, switching the previous layer nodes to be the first n nodes
and the current layer nodes to be the second n nodes. After the second iteration, switch back such that the first
n are the current layer nodes and the second n nodes are the previous layer nodes. This process can be repeated
to reduce the need for a memcopy .

This is a significant optimisation as a layer will contain a sector size worth of nodes which may be as large as
64GiB.

Acceptance criteria

Risks + pitfalls

Where to begin

  1. Determine if the problem description as reported is accurate.

  2. Consider implementing the optimisation described above to reduce copying large quantities of memory.

@cryptonemo
Copy link
Collaborator Author

cc @porcuquine

keyvank added a commit that referenced this issue Jul 9, 2020
#1197)

* opt: Stacked DRG: swap buffers instead of memcpy #1197

* Swap buffers after harvesting results, for clarity.

Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
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 a pull request may close this issue.

2 participants