-
Notifications
You must be signed in to change notification settings - Fork 48
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
Hard-code global tables' contents instead of calculating them at run-time #131
base: master
Are you sure you want to change the base?
Conversation
tables.c: write.c fec.c fec.h Makefile | ||
touch tables.c | ||
gcc -o write write.c && ./write > tables.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
tox.ini
Outdated
@@ -1,5 +1,5 @@ | |||
[tox] | |||
envlist = py37,py38,pypy3 | |||
envlist = py37,py38,py310,pypy3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no 39?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only did that so I could run the tests without downgrading my python. It's off topic really. Maybe there should be another ticket about supporting lots of python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless, 3.7 and 3.8 are already EOL and 3.9 is done in October so all of those should go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR or in a general CI-cleanup one?
#129 would seem a bit more relevant perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI has current configs (and doesn't use tox).
Seems this is merely developer tooling that has been sitting on the shelf for a while?
Either don't touch or fix I guess?
This PR is intended to be merged immediately after #130. On this PR page the present changes are muddled up with those of #130, so I recommend reading this diff instead:
adrianmay/zfec@remove-unsafePerformIO...adrianmay:zfec:init-tables
This PR completely removes
fec_init
and Haskell'sinitialize
, supplying a C file that lists the numbers in the four global tables verbatim. (Tables that depend on n and k are unaffected.)This sidesteps all the difficulties in making sure
fec_init
gets run once (especially in Haskell) and improves performance both by cutting out the run-time calculations and by allowing the 64k table to be loaded into RAM on demand and discarded when not in use.Since #130's version bump was unavoidable, bumping again immediately (because
fec_init
disappears) seems better than the tech-debt of retaining a no-op version offec_init
.tables.c has been generated by a program in write.c which includes fec.c. The program populates the tables using the established logic, and then writes their contents to stdout as initialised arrays in C syntax. A new makefile touches tables.c (because fec.c includes it) and runs the program with its stdout piped to write.c. This has been done and the resulting tables.c committed to source control, so this process is not a pre-build step, rather, write.c is just retained in source control for reference. Code and data that's used purely for table generation has been moved to write.c so it won't bloat the library.