[Haskell-cafe] Haskell-Cafe Digest, Vol 199, Issue 15

Michal J Gajda mgajda at mimuw.edu.pl
Wed Mar 18 14:45:15 UTC 2020


Great idea!

We already have syntax for package imports:
```
import "bytestring" Data.ByteString
```

Source plugin could probably pull and build package by CAS:
```
import "CAS_6ffeacff768590" Data.ByteString
```

That would reuse existing syntax without confusion. And without
inconvenience of having to import expressions one by one.
Or declaring their types.
One could even add CAS hashes to Hackage db.

Wonder if source plugin can add `-package` parameters?

On Wed, Mar 18, 2020, 13:01 <haskell-cafe-request at haskell.org> wrote:

> Send Haskell-Cafe mailing list submissions to
>         haskell-cafe at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> or, via email, send a message with subject or body 'help' to
>         haskell-cafe-request at haskell.org
>
> You can reach the person managing the list at
>         haskell-cafe-owner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Haskell-Cafe digest..."
> Today's Topics:
>
>    1. Re: Help with async library and killing child processes (YueCompl)
>    2. Adding Content-Addressable Storage to GHC (Chris Done)
>
>
>
> ---------- Forwarded message ----------
> From: YueCompl <compl.yue at icloud.com>
> To: Branimir Maksimovic <branimir.maksimovic at gmail.com>
> Cc: haskell-cafe at haskell.org
> Bcc:
> Date: Wed, 18 Mar 2020 18:42:56 +0800
> Subject: Re: [Haskell-cafe] Help with async library and killing child
> processes
> Um, event processing applications by procedural programmers (part data
> analyst personnels for some) is a thing in my org, so I'm baking an DSL
> doing it.
>
> On 2020-03-18, at 18:18, Branimir Maksimovic <
> branimir.maksimovic at gmail.com> wrote:
>
> That's just library, not built into language. You can do it with forkIO as
> I do it per specifics
>
> of application.
>
> Greets,
> Branimir.
> On 3/18/20 11:06 AM, YueCompl wrote:
>
> No, not to cancel a thread, but the business task on that thread's way
> ahead.  That's what Go's Context is designed for.
>
>
>    - About Go context from: https://blog.golang.org/context
>
> At Google, we require that Go programmers pass a Context parameter as the
> first argument to every function on the call path between incoming and
> outgoing requests. This allows Go code developed by many different teams to
> interoperate well. It provides simple control over timeouts and cancelation
> and ensures that critical values like security credentials transit Go
> programs properly.
> Server frameworks that want to build on Context should provide
> implementations of Context to bridge between their packages and those that
> expect a Context parameter. Their client libraries would then accept a
> Context from the calling code. By establishing a common interface for
> request-scoped data and cancelation, Context makes it easier for package
> developers to share code for creating scalable services.
>
> I (and seems Windows api too) strongly agree that cancelling a thread is
> problematic:
>
>
> https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread
>
> TerminateThread is a dangerous function that should only be used in the
> most extreme cases. You should call TerminateThread only if you know
> exactly what the target thread is doing, and you control all of the code
> that the target thread could possibly be running at the time of the
> termination. For example, TerminateThread can result in the following
> problems:
>
>    - If the target thread owns a critical section, the critical section
>    will not be released.
>    - If the target thread is allocating memory from the heap, the heap
>    lock will not be released.
>    - If the target thread is executing certain kernel32 calls when it is
>    terminated, the kernel32 state for the thread's process could be
>    inconsistent.
>    - If the target thread is manipulating the global state of a shared
>    DLL, the state of the DLL could be destroyed, affecting other users of the
>    DLL.
>
>
> On 2020-03-18, at 17:16, Branimir Maksimovic <
> branimir.maksimovic at gmail.com> wrote:
>
> I'm pretty sure you can't cancel goroutine. Actually I have
>
> very bad experience with thread cancelation. Therefore flags
>
> passed via channels/mvars or shared flags are used to stop
>
> threads.
>
> Greets,
> Branimir.
> On 3/18/20 10:10 AM, YueCompl wrote:
>
> Idiomatic resource leakage prevention in short.
>
> An app wants to be as responsive to its users as practically feasible, it
> would try multiple paths to load-balanced resources, and use the first
> response that come back, then cancel other paths. Cancellation can help
> reducing vain computation in such architectures, sometimes largely enough.
>
> On 2020-03-18, at 16:58, Branimir Maksimovic <
> branimir.maksimovic at gmail.com> wrote:
>
> What's wrong with forkIO?
>
> Greets,
> Branimir.
> On 3/18/20 9:37 AM, YueCompl via Haskell-Cafe wrote:
>
> If not for tight loops or other CPU intensive tasks, you may be interested
> in Edh, which introduces Go's goroutine to GHC runtime. But Edh threads add
> much higher overhead on top of GHC threads, so there's a price to pay for
> simplicity of end programmer's job.
>
> It's briefly described at
> https://github.com/e-wrks/edh/tree/master/Tour#program--threading-model .
> This is very new and I'm right now actively working on it for PoC of an STM
> powered in-memory graph database implementation.
>
> Best regards,
> Compl
>
> On 2020-03-18, at 11:15, Niklas Hambüchen <mail at nh2.me> wrote:
>
> I've you're new to async, also check out my recent rework of the docs that
> talk about this topic specifically:
>
> https://github.com/simonmar/async/pull/105/files
>
> (To be available in the next release of async.)
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
>
>
>
>
>
>
> ---------- Forwarded message ----------
> From: Chris Done <haskell-cafe at chrisdone.com>
> To: haskell-cafe at haskell.org
> Cc:
> Bcc:
> Date: Wed, 18 Mar 2020 11:21:29 +0000
> Subject: [Haskell-cafe] Adding Content-Addressable Storage to GHC
> Hi all,
>
> Is there any effort or designs ongoing to add CAS (content-addressable
> storage) to GHC, as in Unison? <
> https://www.unisonweb.org/docs/tour/>
>
> == The idea ==
>
> The summary of the idea is simply that top-level declarations can be
> addressed by a hash of their contents. Recursive definitions are
> transformed into the worker/wrapper to eliminate the self-referencing issue
> of hashing.
>
> == Why I want this ==
>
> There are lots of advantages to this, but the one that excites me the most
> is that we can move to running tests, especially property tests, at
> compile-time.
>
> The main downside to running tests at compile-time, as seen done with
> template-haskell is that you will re-run tests every time the module is
> recompiled, making your dev cycle slower. However, if your tests are keyed
> upon CAS hashes, then those hashes are only invalidated when individual
> declarations actually change. This means the re-running of tests becomes
> granular at the declaration-level.  When a single test completes, either
> successfully or not, you can cache the result and lookup the result next
> time, using e.g. the SHA512 of the expression evaluated.
>
> Therefore you could change a single function in a library and it would
> only re-run the tests that are actually affected, rather than running all
> the tests in the whole module, and rather than the more typical approach
> which is running ALL tests in a test suite just because one thing changed.
>
> If you can couple tests with code then you can avoid the decoupling of
> code from the tests.
>
> == Implementation approaches ==
>
> There are various ways to implement this with varying degrees of
> satisfaction:
>
> 1. Use TH: reify declarations, inspect the AST, and produce a SHA512. Use
> ambient values such as the GHC version, instances in scope, extensions, ghc
> options, etc. With TH, I'm confident that you can only achieve an imperfect
> hash because I doubt that all information is available to TH.
>
> Names that come from external packages could be treated as CAS'd at the
> scope of the package's installed hash. Ideally, you could have granularity
> into other packages. But it's not a necessity if you just want caching for
> your current development package.
>
> 2. Use a source plugin. A source plugin is already capable of accessing
> all GHC context information, so this might lead to more of a perfect hash.
>
> 3. Add it to GHC directly. Exposing a `expressionSHA512 :: Exp ->
> ByteString` could be one imaginary way to access this information. With
> such a function you could implement caching of fine-grained tests.
>
> A related discussion is the deterministic builds:
> https://gitlab.haskell.org/ghc/ghc/wikis/deterministic-builds
>
> Anyone else exploring this?
>
> Cheers,
>
> Chris
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200318/9889da65/attachment.html>


More information about the Haskell-Cafe mailing list