8000 Maybe an incorrect implementation? · Issue #13 · RJ/ketama · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Maybe an incorrect implementation? #13
Open
@YueHonghui

Description

@YueHonghui

Around the line of latest commit:
https://github.com/RJ/ketama/blob/master/libketama/ketama.c#L428

for( i = 0; i < numservers; i++ )
{
        float pct = (float)slist[i].memory / (float)memory;
        unsigned int ks = floorf( pct * 40.0 * (float)numservers );
#ifdef DEBUG
        int hpct = floorf( pct * 100.0 );

        syslog( LOG_INFO, "Server no. %d: %s (mem: %lu = %u%% or %d of %d)\n",
            i, slist[i].addr, slist[i].memory, hpct, ks, numservers * 40 );
#endif

        for( k = 0; k <
51AD
; ks; k++ )
        {

when servers being added into or removed from pool, the ks value of other untouched servers and the points on the circle will be changed. That means hit ratio will be decreased when the pool changed. Why not implement as:

unsigned int ks = 40.0 *  (int)(slist[i].memory);//memory in MB

Do I misunderstand the ketama algorithm or your implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0