简体   繁体   中英

"hill climbing, change max number of threads 5" when debugging on my androiddevice in xamarin forms when I load data

I load data from my DB and when I push buttons to recieve different data I get "hill climbing, change max number of threads 5" in the log, and it makes the app slow when I try to gather the data.

Any idea how to resolve this? Or is this even making the app slower? It sure seems like something is spooky because it takes a few extra seconds when I load data on an android-device compared to an ios.

This is my code:

static public async Task<JObject> getContacts ()
{
    var httpClientRequest = new HttpClient ();
    try {
        var result = await httpClientRequest.GetAsync ("http://address.com");
        var resultString = await result.Content.ReadAsStringAsync ();

        var jsonResult = JObject.Parse (resultString);

        return jsonResult;

    } catch {

        return null;
    }


}

And how I use it:

async void createData (object s, EventArgs a)
{
    var getContacts = await parseAPI.getContacts ();

    if (getContacts != null) {
        listview.ItemsSource = null;
        theList = new List <items> ();

        foreach (var items in getContacts["results"]) {
            theList.Add (new items () {
                Name = items ["Name"].ToString (),
                Number = items ["Number"].ToString ()
            }); 
        }
    }
    listview.ItemsSource = theList;

}

"Hill climbing" is a fairly common within the Mono runtime as the adaptative thread pool count is increasing (or decreasing) based upon current depends.

Personally I doubt that a thread count of 5 is causing any problems within your app. Seeing 30, 50, 100+ could/would be a problem as the thrashing of context switching can/will bring an app (and OS) to its knees.

In terms of OS "speed", the iOS simulator vs. an Android emulator is huge. Instrument and Perf test on actual devices.

The Mono Heuristic thread pool reference:

https://github.com/mono/mono/blob/master/mono/metadata/threadpool-ms.c

hill_climbing_change_thread_count (gint16 new_thread_count, ThreadPoolHeuristicStateTransition transition)
{
    ThreadPoolHillClimbing *hc;

    g_assert (threadpool);

    hc = &threadpool->heuristic_hill_climbing;

    mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_THREADPOOL, "[%p] hill climbing, change max number of threads %d", mono_native_thread_id_get (), new_thread_count);

    hc->last_thread_count = new_thread_count;
    hc->current_sample_interval = rand_next (&hc->random_interval_generator, hc->sample_interval_low, hc->sample_interval_high);
    hc->elapsed_since_last_change = 0;
    hc->completions_since_last_change = 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM