Initialise tables instead of calculating them at run time#128
Closed
adrianmay wants to merge 5 commits intotahoe-lafs:masterfrom
Closed
Initialise tables instead of calculating them at run time#128adrianmay wants to merge 5 commits intotahoe-lafs:masterfrom
adrianmay wants to merge 5 commits intotahoe-lafs:masterfrom
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In fec.c there are four tables whose contents are always the same. (These should not be confused with another table that depends on n and k.)
Their contents are currently calculated when
fec_initis called. It's hard to make sure this happens exactly once. It's also inefficient and rules out loading the tables into RAM on demand and discarding them when not in use.This PR solves this by introducing a file
tables.cin which the tables are initialised. That file was generated by a small program inwrite.cwhich callsfec_initand dumps the tables in C syntax.write.cis not a pre-build step. It's been used once to generatetables.cwhich is in source control.write.cand the Makefile that runs it intotables.cis included in source control for reference only.We could slightly shrink the library by moving the logic that calculates the tables into
write.cbut the MR is presented in the present form to provide assurance that the calculation has not changed.After this, (contrary to what I said in ticket #126) it will still be necessary to convert the haskell wrapper to return IO, which forces a major version bump, in which case we might as well remove initialise. The reason is that
fec_encodeandfec_decodereturn void but populate a passed buffer. Haskell could lazily skip their wrappers unless they returnIO (). This will be done in a subsequent PR.