-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Parallel letter frequency #422
Parallel letter frequency #422
Conversation
I'm a bit reluctant here. Multiple threads isn't really parallelism since the threads aren't executed simultaneously. @fapdash, thoughts? I know a few tracks have foregone this exercise because parallelism is a lot more difficult to pull off than multiple-threading. |
Understood. I think the issue here is emacs in really single threaded, much like javascript, so I don't think we can do true parallelism. We can use a separate process, but I don't know that that would be true to the exercise either. |
from the emacs docs _Emacs Lisp provides a limited form of concurrency, called threads. All the threads in a given instance of Emacs share the same memory. Concurrency in Emacs Lisp is “mostly cooperative”, meaning that Emacs will only switch execution between threads at well-defined times. However, the Emacs thread support has been designed in a way to later allow more fine-grained concurrency, and correct programs should not rely on cooperative threading. Currently, thread switching will occur upon explicit request via thread-yield, when waiting for keyboard input or for process output from asynchronous processes (e.g., during accept-process-output), or during blocking operations relating to threads, such as mutex locking or thread-join. Emacs Lisp provides primitives to create and control threads, and also to create and control mutexes and condition variables, useful for thread synchronization. _ |
@kmarker1101 You can do parallelism via asynchronous processes. You can have a look at how emacs-async has implemented this:
@BNAndras You know better what's in the spirit of the exercise, but I think it's purposefully formulated in a vague way to accommodate language differences, as long as it's running in parallel. |
thanks @fapdash . I will look into it now |
Maybe we could guide students by providing an extra file with a But I think we'd have to add a track specific hint either way. In the hint we could also describe how you would pass code from your solution file to a different process like emacs-async does it and it seems to be a more general solution. |
@kmarker1101 See https://github.com/exercism/emacs-lisp/blob/bfde2aab4cd60302fd8a198e1e5307425a23a11e/exercises/practice/nucleotide-count/.docs/hints.md?plain=1 for an example of a track specific hint. The file needs to have that level-2 heading called
|
interesting why FAILED 4/13 ignore-punctuation is failing CI, but does not fail locally
running in batch also passes locally
|
@BNAndras This should be ready for review now. I am now processing each string in parallel using processes. |
exercises/practice/parallel-letter-frequency/parallel-letter-frequency-test.el
Show resolved
Hide resolved
As @fapdash mentioned, I do want the hints file and the extra file students can use. I believe to have the extra file show up in the UI, you need to add it to the solution array for the files object in the exercise config. |
@fapdash I am a little confused on how a student would use the extra file. Can you give me an example? Also, would the shebang need to change based on platform(ie windows) and location of emacs binary? |
@BNAndras @kmarker1101 I was just thinking out loud when it came to the extra file. I think the current solution is great. Calling an extra executable script vs passing code to What I would suggest:
|
I think we actually want an instructions.append.md since this exercise only has an instructions.md. Otherwise, yeah it's fine to give more track-specific information about what's expected. Python does that a lot, and I've also done it at a few points for Pyret when I'm dealing with a practice exercise that requires something that's not common in the other exercises. Something like "This exercise expects you to work with asynchronous processes blah blah here's a link to documentation" gets the point across. We can add examples later if students are having trouble with just the docs. f they don't use async code, the student is only cheating themselves here so I'm not convinced we need to test if make-process is used. If we do want to add it, I'd say we make this prominent in the test suite so students aren't left thinking this was a hidden requirement. It can be discouraging when your code which should pass all the tests normally instead doesn't. |
exercises/practice/parallel-letter-frequency/.docs/instructions.append.md
Outdated
Show resolved
Hide resolved
exercises/practice/parallel-letter-frequency/.docs/instructions.append.md
Outdated
Show resolved
Hide resolved
@kmarker1101 I've added the extra file for the code supposed to run in the subprocess. Writing code inside of a string must've been painful and not something I think the students should have to deal with. wdyt? |
@BNAndras Can you please verify that my changes to the |
I feel kind of silly now, but I realized that we can put the function for the subprocess into the main solution file, so the additional solution file is not needed. 🤷 |
thanks @fapdash I was missing this piece the whole time. That is why that ugly string was in there. |
@kmarker1101 Yey, I found a way to further simplify the solution code. :) See fae9f65. I had memorized that the printable representation of hash tables can't be read, but that info was wrong:
This leads to problems if you want to mutate those hashtables after reading as
but since we don't want to do this we're good. |
To have additional files in the editor, I think you need to add an |
|
||
The goal of this exercise is to practice parallelism with Emacs Lisp. | ||
|
||
In Emacs Lisp this is achived by using [`asynchronous processes`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html#:~:text=An%20asynchronous%20process%20is%20controlled,%2Dtype%20(see%20below)). |
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 Emacs Lisp this is achived by using [`asynchronous processes`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html#:~:text=An%20asynchronous%20process%20is%20controlled,%2Dtype%20(see%20below)). | |
In Emacs Lisp this can be achieved by using [`asynchronous processes`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html#:~:text=An%20asynchronous%20process%20is%20controlled,%2Dtype%20(see%20below)). |
Small typo fix and grammar fix so we're not saying this is the only way to do parallelism.
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.
done
exercises/practice/parallel-letter-frequency/parallel-letter-frequency-test.el
Outdated
Show resolved
Hide resolved
I'm thinking of bumping this from rep/large (+30) to rep/massive (+100). This has been a bit of an involved PR :) |
@kmarker1101 I made the changes that @BNAndras requested to the parts that I contributed, leaving the rest up to you. |
This should complete the unimplemented 48 in 24 exercises. The solution uses multiple threads.