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

High Resource Usage #12

Closed
AlexPads opened this issue Dec 23, 2019 · 10 comments · Fixed by #17
Closed

High Resource Usage #12

AlexPads opened this issue Dec 23, 2019 · 10 comments · Fixed by #17

Comments

@AlexPads
Copy link

Issue description

  • Expected result: For the plugin to not use 100% CPU usage on a Ryzen 3600 CPU @ 4.0Ghz
  • Actual result: Uses 100%+ CPU when nothing seems to be going on.

Steps to reproduce the issue

  1. Put plugin in server
  2. Start server
  3. View CPU usage at 100% or MUCH higher than it used to be

OS and versions

  • BedcoreProtect: 0.5.2
  • PocketMine-MP: 3.11.1
  • PHP: 7.3
  • Server OS: Ubuntu 1.18 (PHP inside Docker Container)
  • Game version: PE/Win10

Plugins

  • BedcoreProtect

Crashdump, backtrace or other files

Screen Shot 12-23-19 at 12 33 AM

Extra

Tested on:
CPU's:

  • Ryzen 3600X @ 4.0Ghz
  • AMD Phenom X4 @5.0Ghz (OverClocked)
  • Intel Xeon-E 2136
  • Intel i7-7700K
    (I own WitherHosting and have alot of hardware)
    Ram:
  • Samsung DDR3 1666mhz
  • Micron DDR3 and DDR4 2600Mhz
  • Gigabyte DDR4 3000Mhz ECC and non ECC

Included for reference to show they are not like 1 core garbage CPU or Ram setups I have not looked into the plugin but i would assume that it has something to do with a loop getting stuck. or a really rapid listener.

@matcracker
Copy link
Owner

I'm trying to Windows 10 but I can't reproduce the issue.
Do you change something in the configuration file?

@AlexPads
Copy link
Author

Hello mat,

This is a config file from one of our customers experiencing this issue with our your plugin.
It seems to be an issue that is only on Linux hosts i tried on Win10 and got no results but started up my Linux VM and got the same high CPU usage I also started it up on a Linux PC running Debian6 and got same High CPU.

# Plugin language
language: eng

# Database settings
database:
  # The database type. "sqlite" and "mysql" are supported.
  type: sqlite

  # Edit these settings only if you choose "sqlite".
  sqlite:
    # The file name of the database in the plugin data folder.
    # You can also put an absolute path here.
    file: bedcore_database.db
  # Edit these settings only if you choose "mysql".
  mysql:
    host: 127.0.0.1
    # Avoid using the "root" user for security reasons.
    username: root
    password: ""
    # The database name where plugin stores data.
    schema:
  # The maximum number of simultaneous SQL queries
  # Recommended: 1 for sqlite, 2 for MySQL. You may want to further increase this value if your MySQL connection is very slow.
  worker-limit: 1

# The timezone where you are located. This is necessary to correctly log the time of events.
# To find your timezone, check here: https://www.php.net/manual/en/timezones.php
timezone: "Europe/Lisbon"

# A list of worlds where the plugin can track logs
enabled-worlds: []

# If enabled, BedcoreProtect will check for updates when your server starts up.
# If an update is available, you'll be notified via your server console.
check-updates: true

# If no radius is specified in a rollback or restore, this value will be
# used as the radius. Set to "0" to disable automatically adding a radius.
default-radius: 10

# The maximum radius that can be used in a command. Set to "0" to disable.
# To run a rollback or restore without a radius, you can use "r:#global".
max-radius: 100

# If enabled, items taken from containers (etc) will be included in rollbacks.
rollback-items: true

# If enabled, entities, such as killed animals, will be included in rollbacks.
rollback-entities: true

# Logs blocks placed by players.
block-place: true

# Logs blocks broken by players.
block-break: true

# Logs blocks that break off of other blocks; for example, a sign or torch
# falling off of a dirt block that a player breaks.
natural-break: true

# Properly track block movement, such as sand or gravel falling.
block-movement: true

# Logs blocks that burn up in a fire.
block-burn: true

# Logs when a block naturally ignites, such as from fire spreading.
block-ignite: true

# Logs explosions, such as TNT and Creepers.
explosions: true

# Track when an entity changes a block, such as an Enderman destroying blocks. (NOT FULLY IMPLEMENTED IN POCKETMINE YET)
entity-change: true

# Logs killed entities, such as killed cows and enderman.
entity-kills: true

# Logs text on signs. If disabled, signs will be blank when rolled back.
sign-text: true

# Logs lava and water sources placed/removed by players who are using buckets.
buckets: true

# Logs natural tree leaves decay.
leaves-decay: true

# Logs tree growth. Trees are linked to the player who planted the sappling. (NOT IMPLEMENTED IN POCKETMINE YET)
tree-growth: true

# Logs mushroom growth. (NOT IMPLEMENTED IN POCKETMINE YET)
mushroom-growth: true

# Logs natural vine growth. (NOT IMPLEMENTED IN POCKETMINE YET)
vine-growth: true

# Logs water flow. If water destroys other blocks, such as torches,
# this allows it to be properly rolled back.
water-flow: true

# Logs lava flow. If lava destroys other blocks, such as torches,
# this allows it to be properly rolled back.
lava-flow: true

# Allows liquid to be properly tracked and linked to players.
# For example, if a player places water which flows and destroys torches,
# it can all be properly restored by rolling back that single player.
liquid-tracking: true

# Track item transactions, such as when a player takes items from a
# chest, furnace, or dispenser. Necessary for any item based rollbacks.
item-transactions: true

# Track player interactions, such as when a player opens a door, presses
# a button, or opens a chest. Player interactions can't be rolled back.
player-interactions: true

# Logs changes made via the plugin "BlockSniper" if it's in use on your server.
blocksniper-hook: false

@matcracker
Copy link
Owner

Hi Alex,
this is the default plugin configuration.
I will install VM based on Linux OS to try debug the problem. Give me some days because there is Christmas event.

Thank you!

@matcracker matcracker added Status: Reproduced Bug has been reproduced, but cause has not yet been identified and removed Resolution: Cannot Reproduce labels Dec 23, 2019
@matcracker
Copy link
Owner

I reproduced the issue and... Yes, it only happens on linux OS. I need more time to debug it.

@matcracker
Copy link
Owner

Hi Alex, after some tests, I found the cause. It is caused from the library "libasynql" that manage the database. Unfortunately, I can't fix the issue because it does not depend from me. The library's author is already aware.

@matcracker matcracker added Status: Debugged Cause of the bug has been found, but not fixed Resolution: Won't fix This will not be worked on and removed Status: Reproduced Bug has been reproduced, but cause has not yet been identified labels Jan 3, 2020
@AlexPads
Copy link
Author

AlexPads commented Jan 3, 2020

R.I.P

@matcracker
Copy link
Owner

matcracker commented Apr 10, 2020

Issue seems to be fixed now they made a new pull request, and its accepted now.
poggit/libasynql#26

Yes, I have seen the new version of libasynql. I am currently working on a new version of BedcoreProtect v0.6.0 which aims to improve even more the performance and contains many bug fixes so far undiscovered!
When I am in the final phase, I will try to update libasynql to v3.3 and do some tests.

@matcracker
Copy link
Owner

Hi @AlexPads and @enescaglayan, I am offering you a usable beta version of BedcoreProtect v0.6.0 to check if this issue persists.
The version is stable but since it is a beta I advise you not to use it on a production server.

Please, let me know. Thanks in advance.

@Crypt97 Crypt97 mentioned this issue Apr 25, 2020
matcracker added a commit that referenced this issue May 8, 2020
# Introductory notes
- **This update is recommended because it contains many improvements and bug fixes.**
- The update is backward compatible with **v0.5.x**
- If you are already using BedcoreProtect **v0.5.x** and you upgrade to **v0.6.0, you will notice a message of database upgrading**. Don't worry, that's normal. It's the patch manager process that updates the database tables for the new version. **If during the process you got a crash, please open a issue [here](https://github.com/matcracker/BedcoreProtect/issues/new/choose)!**

# Changelog (Last update: 08/05/2020)
The update is not finished yet and the changelog could be updated in any time.

## Features
- Added /bcp undo command _(Permission: bcp.subcommand.undo)_. Allows to undo the last rollback/restore.
- Now block restrictions works. So, is now possible to include/exclude certain blocks during a rollback or a lookup.
- When a player spawn an entity through a spawn egg is now logged.
- When a entity dies due to a block (e.g. fire, lava, etc...) is now logged.
- When a player ignites a TNT is now logged.
- Code analyzed with PHPStan level 8.

## Improvements
- With SQLite the data will be saved every 5 minutes (same as worlds) instead of 5 hours.
- Re-wrote query execution code getting a speed up!
- Most of queries when executed are now scheduled in order by preventing missing or wrong logs.
- Improved the QueryGenerator execution.
- Improved painting break tracking.
- Removed tiles when rollback placed blocks.
- General minor improvements.

## Changes
- The patch manager is now able to patch a different numbers of patches for each database type.
- From now in the database version of status command (/bcp status) will be applied a suffix indicating if the current database version is backward compatible. 
_(e.g. - Database version: v0.6.1 (Backward Compatible))_
- Default SQLite database file name is now **logs.db**. (This change is backward compatible)

## Bug fixes
- Fixed #9 
- Fixed #12 
- Fixed an issue not allowing inspector to getting logs of the replaced block.
- Fixed crash during the rollback of entities.
- Fixed possible issue with command permission check order.
- Fixed order of plugin data folder creation.
- Fixed wrong position calculation of liquid tracking.
- Fixed correct meta value (damage) when placing block.
- Fixed wrong restore of bed and doors when placed.
- Fixed duplicated door log when breaking.
- Fixed block burning rollback not correctly working some times.
- Fixed purge command not correctly working on SQLite.
- Fixed excessive log during inventory transaction.
- Fixed database file creation on start-up not taking the choosed file name in the config.
- Fixed possibles crashes relative to null values while tracking.
- When rollback an area containing blocks with light source, the light will try to be updated. (This avoid empty light areas)
- Don't log anymore players when they die. It causes a crash while rollback.
@matcracker matcracker added Resolution: Fixed and removed Resolution: Won't fix This will not be worked on Status: Debugged Cause of the bug has been found, but not fixed labels May 9, 2020
@vkamz597 vkamz597 mentioned this issue Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@matcracker @AlexPads and others