build ghc with make (ghc-boot-th broken deps)

Daneel Yaitskov dyaitskov at gmail.com
Thu May 21 02:01:36 UTC 2020


Hi Ben,

Thanks for bothering.
I solved issue.
That was ancient cabal.
I build ghc successfully once I installed Cabal-3.
I thought that configure script will warn me about incompatible cabal :)

Btw could you shed some light on RTS locking?

I am interested in:

    ccall traceUserBinaryMsg(MyCapability() "ptr", msg "ptr", len);

because it looks slower on smaller chunks.
Writing data in 64 bytes chunks vs 4k (ghc 8.11) is twice slower.

https://github.com/yaitskov/eventslog-benchmark
benchmark [      LoadWithBinary-b1048576-t001-c0064] lasted for cpu
4.23 ms real 4.24 ms
benchmark [      LoadWithBinary-b1048576-t001-c0128] lasted for cpu
3.97 ms real 3.91 ms
benchmark [      LoadWithBinary-b1048576-t001-c1024] lasted for cpu
2.73 ms real 2.61 ms
benchmark [      LoadWithBinary-b1048576-t001-c2048] lasted for cpu
2.34 ms real 2.23 ms
benchmark [      LoadWithBinary-b1048576-t001-c4096] lasted for cpu
2.16 ms real 2.20 ms

Eventlog messages tend to be small.
So application developer has to think about bufferization to speed up.
OpenTelemetry gains 6x speed improvement with following hack.

mm :: IO (IORef (Int, Builder))
mm = newIORef (0, mempty)

traceBuilder :: MonadIO m => (Int, Builder) -> m ()
traceBuilder !sizedBuilder@(size, builder) = do
  liftIO $! do
    tls <- G.mkTLS mm
    ref <- G.getTLS tls
    (!bufferedSize, !bufferedBuilders) <- readIORef ref
    if bufferedSize + size > 1024
    then do
      traceBinaryEventIO . LBS.toStrict $! toLazyByteString bufferedBuilders
      writeIORef ref sizedBuilder
    else do
      writeIORef ref (bufferedSize + size, builder <> bufferedBuilders)



I see that some EventLog methods use mutexes, but user message function don't.
It just appends to buffer and can flush if it is full.
So I don't see where locking happening.
MyCapability is just arithmetic

#define MyCapability()  (BaseReg - OFFSET_Capability_r)

I guess capability locking happens somewhere upper - before C.

How to register RTS function, which would don't acquire capability lock?
I think locking for this case could be replaced with atomic variable.
C11 standard provides such IPC abstraction.

Thanks,
Daniil

On 5/20/20, Ben Gamari <ben at smart-cactus.org> wrote:
> Daneel Yaitskov <dyaitskov at gmail.com> writes:
>
>> Hi List,
>>
>> I pulled ghc repo (568d7279a) and trying to build with following env:
>> Ghc from stack (8.8.3). I made links to ghc and ghc-pkg in /usr/bin
>>
> Hi Daneel,
>
>> ./boot is passing well, but ./configure breaks on ghc-boot step.
>> I have no idea how could I fix this issue.
>>
> Can you offer more detail here? How precisely does it break? Can you
> paste the full output from ./configure?
>
> Cheers,
>
> - Ben
>
>


-- 

Best regards,
Daniil Iaitskov


More information about the ghc-devs mailing list