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

Optimization using bytestring #25

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

msakai
Copy link
Collaborator

@msakai msakai commented Mar 17, 2020

Attempt for optimization using bytestring (#24).

  • read file as lazy ByteString and feed it to Alex directly without going through String (Note that Alex internally uses UTF-8),
  • dump formula into bytestring Builder instead of ShowS.
  • use ByteString for internal representation for some types (V, AtomicWord, Role, DistinctObjectTerm)

Compatibility is kept to some extent using PatternSynonyms extension.

As I show below, maximum residency is reduced significantly, but I'm still not sure if it is worth its implementation complexity.

Experiments

I compiled TestImportExportImportFile using GHC 8.6.5 + Stackage LTS 14.20 using stack build --executable-profiling --flag logic-TPTP:BuildTestPrograms, and ran echo TPTP-v7.3.0/Problems/HWV/HWV122-1.p | TestImportExportImportFile False +RTS -p -s on master (4ef0ec9) and on this bytestring branch (6cb34a6) three times for each and take average of profile information.

Result

Time/allocation profile (-p):

before after
total time 11.14 secs 10.66 secs
total alloc (excludes profiling overheads) 6,864,859,344 bytes 7,661,934,288 bytes

Summary GC statistics (-s):

before after
allocated in the heap 11,053,555,346 bytes 12,196,062,090 bytes
copied during GC 2,644,563,434 bytes 2,403,806,042 bytes
maximum residency 459,088,146 bytes 266,768,733 bytes
maximum slop 2,519,392 bytes 2,328,909 bytes
total memory in use 437 MB 254 MB

Discussion

Total allocation increased a little (+11.6 %). I guess this is caused by increased conversion between types.

On the other hands, maximum residency is reduced significantly (-41.9 %).

Execution time is reduced a little (-4.3 %), but this may be by chance.

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.

1 participant