Giter VIP home page Giter VIP logo

baseclustering's People

Contributors

pustalorc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

diffoz

baseclustering's Issues

CPU Spikes when buildables are processed

This is going to be documented here, as DiFFoZ reported it as happening, and it is a known issue but not obvious at first due to the deferred and multi-threaded nature of buildable processing.

To be clear: the problem lies within the clustering part of the plugin, as its extremely inefficient at this moment for one-to-one changes, but works much better in bulk.
However, it still takes quite some time to finish processing, and of course, spikes the CPU up due to its inefficiency.

Currently, the following actions must be caught for clustering to work as intended:

  • A buildable is removed
  • A buildable is added
  • A buildable changes its position (Note, this is basically the same as removing a buildable and adding it elsewhere. This is how it is handled internally)

From that, the clusters should do one of the following actions:

  1. Shrink the cluster (remove the affected buildables)
  2. Split the cluster (a buildable connected 2 other buildables within the same cluster, which are no longer connected under any circumstance)
  3. Expand the cluster (add any connected buildables)
  4. Merge the cluster (a buildable now connects 2 separate clusters together)

Additionally, any of the following actions should happen where necessary:

  • A cluster with no more buildables, or unneeded is returned to the object pool for use in the future
  • A cluster that expands must steal barricades from the global cluster which are now in range
  • A cluster that shrinks must return barricades to the global cluster which are no longer in range

The code that handles all of this is split in a couple locations:

Cluster shrinking, splitting and returning: https://github.com/Pustalorc/BaseClustering/blob/master/API/BaseClusters/BaseCluster.cs#L281

Cluster expansion, merging and stealing: https://github.com/Pustalorc/BaseClustering/blob/master/API/BaseClusters/BaseClusterDirectory.cs#L525

If anyone has any ideas for optimizing or improving this entire workload, feel free to open a PR or comment here.

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.