Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4544822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:43:32+00:00 2026-05-21T15:43:32+00:00

Here’s my implementation of a sort of treap (with implicit keys and some additional

  • 0

Here’s my implementation of a sort of treap (with implicit keys and some additional information stored in nodes): http://hpaste.org/42839/treap_with_implicit_keys

According to profiling data GC takes 80% of time for this program. As far as I understand, it’s caused by the fact that every time a node is ‘modified’, each node on the path to the root is recreated.

Is there something I can do here to improve performance or I have to descend into the realm of ST monad?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:43:33+00:00Added an answer on May 21, 2026 at 3:43 pm

    Using GHC 7.0.3, I can reproduce your heavy GC behavior:

      $ time ./A +RTS -s
      %GC time      92.9%  (92.9% elapsed)
      ./A +RTS -s  7.24s user 0.04s system 99% cpu 7.301 total
    

    I spent 10 minutes going through the program. Here’s what I did, in order:

    • Set GHC’s -H flag, increasing limits in the GC
    • Check unpacking
    • Improve inlining
    • Adjust the first generation allocation area

    Resulting in a 10 fold speedup, and GC around 45% of time.


    In order, using GHC’s magic -H flag, we can reduce that runtime quite a bit:

      $ time ./A +RTS -s -H
      %GC time      74.3%  (75.3% elapsed)
      ./A +RTS -s -H  2.34s user 0.04s system 99% cpu 2.392 total
    

    Not bad!

    The UNPACK pragmas on the Tree nodes won’t do anything, so remove those.

    Inlining update shaves off more runtime:

     ./A +RTS -s -H  1.84s user 0.04s system 99% cpu 1.883 total
    

    as does inlining height

     ./A +RTS -s -H  1.74s user 0.03s system 99% cpu 1.777 total
    

    So while it is fast, GC is still dominating — since we’re testing allocation, after all.
    One thing we can do is increase the first gen size:

     $ time ./A +RTS -s -A200M
     %GC time      45.1%  (40.5% elapsed)
     ./A +RTS -s -A200M  0.71s user 0.16s system 99% cpu 0.872 total
    

    And increasing the unfolding threshold, as JohnL suggested, helps a little,

     ./A +RTS -s -A100M  0.74s user 0.09s system 99% cpu 0.826 total
    

    which is what, 10x faster than we started? Not bad.


    Using ghc-gc-tune, you can see runtime as a function of -A and -H,

    Time and GC

    Interestingly, the best running times use very large -A values, e.g.

    $ time ./A +RTS -A500M   
    ./A +RTS -A500M  0.49s user 0.28s system 99% cpu 0.776s
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my persistence.xml : <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd version=1.0>
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here's my Manifest: <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.mappp.mobile android:versionCode=1 android:versionName=1.0 > <supports-screens android:largeScreens=true
Here is a screenshot of the problem (in IE): http://img401.imageshack.us/img401/7580/screenield.jpg The above effect -
Here an example of my checkbox list http://jsfiddle.net/YnM2f/ Let's say I check on G
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here is an example: I have a file 1.js, which has some functions. I
here is the scenario 1: user starts to type some word, autocomplete engine shows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.