Skip to content

[WIP] Optimize bash and python - #75

Open
svanoort wants to merge 5 commits into
juditacs:masterfrom
svanoort:optimize-bash-and-python
Open

svanoort wants to merge 5 commits into
juditacs:masterfrom
svanoort:optimize-bash-and-python

Conversation

@svanoort

@svanoort svanoort commented Apr 3, 2016

Copy link
Copy Markdown
Contributor

Replaces #72 since similar changes have gotten pulled into
other PRs and I don't want merge conflicts.

Benchmark: time cat data/huwikisource-latest-pages-meta-current.xml | mycommand > /dev/null
System: Macbook Pro mid-2014 edition, 2.2 GHz Core i7
Times: real / CPU/ sys

Bash optimization history:
0. Baseline: 30.472s / 34.201s / 0.953s - output md5sum: 8ed673317ddae1eca0f0f76bb4b4605e

  1. Bash script with more efficient sed + prefiltering + memory buffering of sort: 29.718s / 32.341s / 0.611s - output md5sum: e626474108822357e59507b26fa90f6a

Need to reconcile that difference here, it was not that way before

Note that with Mac we don't get parallel sort here. If I run the second one in an ubuntu:16.04 docker machine on the same host.

Bash TODOS:

  • Verify bash generates correct output on Mac vs. Linux (line separator & UNIX vs Linux differences are causing problems)

Python optimizations:

  1. Baseline: 25.631s / 25.145s / 0.493s - output md5sum b52070c4fdd3b0b87ea5659e2e862128
  2. Remove UTF-8 encode/decode, and directly sort list: 14.633s / 14.302s / 0.368s - output md5sum: b52070c4fdd3b0b87ea5659e2e862128
  3. Group together words with same count for sorting: 11.633s / 11.367s / 0.315s - output md5sum: b52070c4fdd3b0b87ea5659e2e862128
  4. Rather than trying to sort count,index integers, collect lists of words with equal count directly 9.432s / 9.346s / 0.233s: - output md5sum: b52070c4fdd3b0b87ea5659e2e862128
  5. Radix sort (or lexicographic sort using a lookup table, which is mapped onto a radix sort).

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