Git Product home page Git Product logo

gna's People

Contributors

padeir0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

nedenwalker

gna's Issues

group: dispatchers doing duplicate work

https://github.com/kazhmir/gna/blob/7c6ca39c05dc1666adbea025b151731860cb3d52/group.go#L52

This creates an exponential relationship between number of players in the server and number of encodings. When #players > 100, the gob.Encode function takes most of the execution time, while encoding the same object, limiting the maximum number of players to ~365 in my machine.

If the Group encodes and send the raw bytes to each dispatcher it should cut it. Although i'm not sure how to do it without the gob complaining.

Something on the lines of:

func (g *Group) ship(dt interface{}) {
        g.mu.Lock()
        defer g.mu.Unlock()
        var b bytes.Buffer
        enc := gob.NewEncoder(&b)
        err := enc.Encode(&dt)
        if err != nil {
                return
        }
        bff := b.Bytes()
        raw := make([]byte, len(bff))
        copy(raw, bff)
        for _, p := range g.pMap {
                p.shipRaw(raw)
        }
}

But this is kind of ugly and makes gob spit out "duplicate type received".
Reusing the encoder and buffer makes the gob complain: "corrupted data" and "unknown type".
I may try a MultiWriter, but i'm not sure how the write errors are going to be handled this way.

I will need to dig through the gob internals and try out some options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.