juditacs / wordcount

Counting words in different programming languages.
123 stars 67 forks source link

Concurrency or not concurrency? #57

Open NobbZ opened 8 years ago

NobbZ commented 8 years ago

There is that rule in the README:

  • single-thread is preferred but you can add multi-threaded or multicore versions too

This reads as if there shall be a singlethreaded contribution for a language, and then multithreaded contributions can be added as seperate entries.

Now there was this cleanup which threw out quite a lot of programs in languages that had multiple entries.

Since Elixir is a language that bets on concurrency, I'd like to retry a concurrent version before starting this in Erlang.

So how do we handle this?

It would be very easy to add a CLI-switch/subcommand to the script which does enable/disable concurrency easily, but then still the question remains, how to handle it during the runs?

juditacs commented 8 years ago

I see two possibilities for each language:

  1. concurrency can be enabled with a cli-switch/subcommand/whatever, the code is the same
  2. the concurrent code is different from the single-threaded,

If we choose the Makefile structure you suggested, there could be a run and a run-parallel command (if it is implemented). What do you think?

NobbZ commented 8 years ago

Sounds reasonable.

michaelortmann commented 9 months ago

the java implementation uses threading:

$ cat data/huwiki-latest-pages-meta-current.xml | /usr/bin/time -v java -Xms2G -Xmx8G -classpath java:java/zah-0.6.jar WordCountOptimized >out-java.txt
[...]
    Percent of CPU this job got: 141%
[...]
$ java --version
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13)
OpenJDK 64-Bit Server VM (build 21.0.2+13, mixed mode, sharing)
[...]