Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitswap Rounds CR suggestions #2 #459

Merged
merged 41 commits into from
Dec 17, 2014

Commits on Dec 17, 2014

  1. fix(test): nil Blockstore

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    7281f66 View commit details
    Browse the repository at this point in the history
  2. style: line wrapping

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    260629e View commit details
    Browse the repository at this point in the history
  3. fix: move to callsite so public callers don't experience the internal…

    … timeout rule
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    32ae1f9 View commit details
    Browse the repository at this point in the history
  4. style constify variables

    good to const until it's required for them to be variable.
    
    TODO pass them in as configuration options
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    b188a2c View commit details
    Browse the repository at this point in the history
  5. refactor: change Tasks to Outbox

    notice that moving the blockstore fetch into the manager removes the
    weird error handling case.
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    0056361 View commit details
    Browse the repository at this point in the history
  6. refactor: avoid loop reuse

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    bb92988 View commit details
    Browse the repository at this point in the history
  7. fix: move the check into the function.

    function should be a no-op when passed an empty slice
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    4e1818d View commit details
    Browse the repository at this point in the history
  8. refactor: context first in argument list

    (merely by convention)
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    0d77e02 View commit details
    Browse the repository at this point in the history
  9. doc: comment

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    be87976 View commit details
    Browse the repository at this point in the history
  10. refactor: taskKey := p.Key() + block.Key()

    for clarity and to avoid errors, define a function
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    fda0617 View commit details
    Browse the repository at this point in the history
  11. unexport task and taskList

    the less bitswap has to know about, the easier it'll be for readers.
    (This now returns Messages.)
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    68ae09f View commit details
    Browse the repository at this point in the history
  12. refactor: remove peerKey type

    we've been using maps with peers long enough now that this probably is
    no longer necessary
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    9d2c54c View commit details
    Browse the repository at this point in the history
  13. add comment to fix race

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    9259f66 View commit details
    Browse the repository at this point in the history
  14. perf: avoid lots of communication by signaling once at end of method

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    3d1d19c View commit details
    Browse the repository at this point in the history
  15. it's not a queue yet but it's okay to name it as such

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    f7310a4 View commit details
    Browse the repository at this point in the history
  16. tq.Cancel -> tq.Remove

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    9a6bb16 View commit details
    Browse the repository at this point in the history
  17. privatize Task

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    72584ec View commit details
    Browse the repository at this point in the history
  18. doc: add comment to Envelope

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    09ab411 View commit details
    Browse the repository at this point in the history
  19. refactor: re-use wantlist.Entry type wherever it makes sense

    it seems to make sense since, in each place, the Key and Priority
    represent the same information
    
    b/c you know the saying...
    
    "It is better to have 100 functions operate on one data structure than
    10 functions on 10 data structures."
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    39ee5eb View commit details
    Browse the repository at this point in the history
  20. refactor: separate responsibilties

    Before, priority carried two pieces of information.
    
    One: priority as defined by remote peer
    Two: whether task is trashed
    
    This assumes the protocol is defined for natural numbers instead of
    integers. That may not always be the case. Better to leave that
    assumption outside so this package isn't coupled to the whims of the
    protocol.
    
    The protocol may be changed to allow any integer value to be used.
    Hopefully by that time, new responsibilties weren't added to the
    Priority variable.
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    37b1f50 View commit details
    Browse the repository at this point in the history
  21. mv comment

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    b23869f View commit details
    Browse the repository at this point in the history
  22. refactor: remove ledgerMap type

    it's only used in two places, but i think we've been using maps on IPFS
    types so much now that the specificity is no longer necessary
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    b0a2ee6 View commit details
    Browse the repository at this point in the history
  23. refactor: put mutex next to the things it protects

    If we put the lock next to the fields it protects, it can sometimes make
    it easier to reason about threadsafety.
    
    In this case, it reveals that the task queue (not threadsafe) isn't protected by the
    mutex, yet shared between the worker and callers.
    
    @whyrusleeping
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    87e94f9 View commit details
    Browse the repository at this point in the history
  24. refactor: wantlist splits into WL and ThreadSafe WL

    bitswap keeps the threadsafe version. observing the ledger shows that it
    doesn't need it anymore (ledgermanager is protected and safe).
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    81c0979 View commit details
    Browse the repository at this point in the history
  25. rename to strategy.LedgerManager to decision.Engine

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    aac777d View commit details
    Browse the repository at this point in the history
  26. rm empty file

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    1a2e9ee View commit details
    Browse the repository at this point in the history
  27. rename to peerRequestQueue

    this opens up the possibility of having multiple queues. And for all
    outgoing messages to be managed by the decision engine
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    d5bb556 View commit details
    Browse the repository at this point in the history
  28. fix: don't sort the output of Entries()

    only sort SortedEntries()
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    666ac0b View commit details
    Browse the repository at this point in the history
  29. rm unused method

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    72965e6 View commit details
    Browse the repository at this point in the history
  30. add comment

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    167fbac View commit details
    Browse the repository at this point in the history
  31. unexport functions

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    7b93d74 View commit details
    Browse the repository at this point in the history
  32. fix: check blockstore before adding task

    addresses #438 (comment)
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    f5133db View commit details
    Browse the repository at this point in the history
  33. log unusual event

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    61ab0df View commit details
    Browse the repository at this point in the history
  34. fix: set peerset size

    addresses #438 (comment)
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    6edef72 View commit details
    Browse the repository at this point in the history
  35. doc: peerset fixme

    not changing this because i don't want to write a test for it now
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    76889a8 View commit details
    Browse the repository at this point in the history
  36. refactor: *Entry -> Entry

    in many places, entries are assigned from one slice to another and in
    different goroutines. In one place, entries were modified (in the
    queue). To avoid shared mutable state, probably best to handle entries
    by value.
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    2c834af View commit details
    Browse the repository at this point in the history
  37. extract constants

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    fd1da4c View commit details
    Browse the repository at this point in the history
  38. refactor(bs/decision.Engine): pass in Entry

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    07c6a8b View commit details
    Browse the repository at this point in the history
  39. fix: add lock to taskQueue

    @whyrusleeping may wanna have a look and make sure i didn't screw
    anything up here
    
    BenchmarkInstantaneousAddCat1MB-4            200          10763761 ns/op
    97.42 MB/s
    BenchmarkInstantaneousAddCat2MB-4       panic: runtime error: invalid
    memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x0 pc=0xbedd]
    
    goroutine 14297 [running]:
    github.com/jbenet/go-ipfs/exchange/bitswap/decision.(*taskQueue).Remove(0xc2087553a0,
            0xc2085ef200, 0x22, 0x56f570, 0xc208367a40)
        /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/decision/taskqueue.go:66
        +0x82
    github.com/jbenet/go-ipfs/exchange/bitswap/decision.(*Engine).MessageSent(0xc20871b5c0,
            0x56f570, 0xc208367a40, 0x570040, 0xc208753d40, 0x0, 0x0)
        /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/decision/engine.go:177
        +0x29e
    github.com/jbenet/go-ipfs/exchange/bitswap.(*bitswap).send(0xc20871b7a0,
            0x56f4d8, 0xc208379800, 0x56f570, 0xc208367a40,
            0x570040, 0xc208753d40, 0x0, 0x0)
        /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:352
        +0x11c
    github.com/jbenet/go-ipfs/exchange/bitswap.(*bitswap).taskWorker(0xc20871b7a0,
            0x56f4d8, 0xc208379800)
        /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:238
        +0x165
        created by
        github.com/jbenet/go-ipfs/exchange/bitswap.New
        /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:66
        +0x49e
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    d36c480 View commit details
    Browse the repository at this point in the history
  40. doc: some comments about the future of the decision engine

    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    fa6e63c View commit details
    Browse the repository at this point in the history
  41. fix: batches of blocks have equal priority

    addresses...
    
    https://github.com/jbenet/go-ipfs/pull/438/files#r21878994
    
    License: MIT
    Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
    Brian Tiger Chow committed Dec 17, 2014
    Configuration menu
    Copy the full SHA
    aaa46cc View commit details
    Browse the repository at this point in the history