Skip to content

Commit bc405ab

Browse files
committed
Memory and performance improvements
20-30% faster update -35% less memory used in update -5% less memory stored after update 135 MB lower memory footprint Bug fix: Garbage collection now run after update
1 parent 87ecf5e commit bc405ab

18 files changed

+68
-49
lines changed

ArkBot/Ark/ArkClusterContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private set
4242
}
4343
}
4444

45-
public ArkClusterContext(ClusterConfigSection config) : base(config.SavePath)
45+
public ArkClusterContext(ClusterConfigSection config) : base(config.SavePath, true)
4646
{
4747
Config = config;
4848
}

ArkBot/Ark/ArkContextManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ private void Context_VoteInitiated(ArkServerContext sender, VoteInitiatedEventAr
172172

173173
private void Context_UpdateCompleted(IArkUpdateableContext sender, bool successful, bool cancelled)
174174
{
175+
// Force an immediate garbage collection because it seems more effective (extraction process requires a great deal of memory)
176+
GC.Collect();
177+
175178
// When all server contexts have completed one update successfully trigger the InitializationCompleted-event.
176179
if (!IsFullyInitialized && Servers.All(x => x.IsInitialized) && Clusters.All(x => x.IsInitialized))
177180
{

ArkBot/Ark/ArkServerContext.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,17 @@ public TimeSpan? ApproxTimeUntilNextUpdate
130130
}
131131
}
132132

133-
public ArkServerContext(IConfig fullconfig, ServerConfigSection config, ArkClusterContext clusterContext, ISavedState savedState, ILifetimeScope scope) : base(config?.SaveFilePath, clusterContext, fullconfig.SavegameExtractionMaxDegreeOfParallelism)
133+
public ArkServerContext(
134+
IConfig fullconfig,
135+
ServerConfigSection config,
136+
ArkClusterContext clusterContext,
137+
ISavedState savedState,
138+
ILifetimeScope scope)
139+
: base(
140+
config?.SaveFilePath,
141+
clusterContext,
142+
fullconfig.SavegameExtractionMaxDegreeOfParallelism,
143+
true)
134144
{
135145
Config = config;
136146
_clusterContext = clusterContext;

ArkBot/ArkBot.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
<HintPath>..\packages\Accord.Statistics.3.5.0\lib\net46\Accord.Statistics.dll</HintPath>
6767
<Private>True</Private>
6868
</Reference>
69-
<Reference Include="ArkSavegameToolkitNet, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
70-
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\external\ArkSavegameToolkitNet\$(Configuration)\ArkSavegameToolkitNet.dll</HintPath>
69+
<Reference Include="ArkSavegameToolkitNet, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\packages\ArkSavegameToolkitNet.1.1.0\lib\net461\ArkSavegameToolkitNet.dll</HintPath>
71+
<Private>True</Private>
7272
</Reference>
73-
<Reference Include="ArkSavegameToolkitNet.Domain, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
74-
<SpecificVersion>False</SpecificVersion>
75-
<HintPath>..\external\ArkSavegameToolkitNet\$(Configuration)\ArkSavegameToolkitNet.Domain.dll</HintPath>
73+
<Reference Include="ArkSavegameToolkitNet.Domain, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
74+
<HintPath>..\packages\ArkSavegameToolkitNet.1.1.0\lib\net461\ArkSavegameToolkitNet.Domain.dll</HintPath>
75+
<Private>True</Private>
7676
</Reference>
7777
<Reference Include="Autofac, Version=4.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
7878
<HintPath>..\packages\Autofac.4.3.0\lib\net45\Autofac.dll</HintPath>

ArkBot/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
xmlns:prism="http://prismlibrary.com/"
1616
mc:Ignorable="d"
1717
x:Name="mainWindow"
18-
Title="ARK Discord Bot" MinWidth="800" MinHeight="600" Width="800" Height="600" WindowStartupLocation="CenterScreen" Icon="basket_empty.ico">
18+
Title="ARK Bot" MinWidth="800" MinHeight="600" Width="800" Height="600" WindowStartupLocation="CenterScreen" Icon="basket_empty.ico">
1919
<i:Interaction.Triggers>
2020
<i:EventTrigger EventName="Closing">
2121
<prism:InvokeCommandAction Command="{Binding ClosingCommand}" />

ArkBot/Properties/AssemblyInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// General Information about an assembly is controlled through the following
77
// set of attributes. Change these attribute values to modify the information
88
// associated with an assembly.
9-
[assembly: AssemblyTitle("ARK Discord Bot")]
10-
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyTitle("ARK Bot")]
10+
[assembly: AssemblyDescription("ARK Survival Evolved application that monitors and extracts data from local ARK servers and exposes this data through a Web App, Web API and Discord Bot.")]
1111
[assembly: AssemblyConfiguration("")]
1212
[assembly: AssemblyCompany("")]
13-
[assembly: AssemblyProduct("ArkDiscordBot")]
14-
[assembly: AssemblyCopyright("Copyright © 2017")]
13+
[assembly: AssemblyProduct("ArkBot")]
14+
[assembly: AssemblyCopyright("Copyright © 2017")]
1515
[assembly: AssemblyTrademark("")]
1616
[assembly: AssemblyCulture("")]
1717

@@ -44,5 +44,5 @@
4444
// You can specify all the values or you can default the Build and Revision Numbers
4545
// by using the '*' as shown below:
4646
// [assembly: AssemblyVersion("1.0.*")]
47-
[assembly: AssemblyVersion("1.69.*")]
48-
[assembly: AssemblyFileVersion("1.69.0.0")]
47+
[assembly: AssemblyVersion("1.70.*")]
48+
[assembly: AssemblyFileVersion("1.70.0.0")]

ArkBot/ViewModel/Workspace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void WriteAndWaitForKey(params string[] msgs)
193193

194194
internal async Task Init()
195195
{
196-
System.Console.WriteLine("ARK Discord Bot");
196+
System.Console.WriteLine("ARK Bot");
197197
System.Console.WriteLine("------------------------------------------------------");
198198
System.Console.WriteLine();
199199

ArkBot/WebApi/Controllers/MapController.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,26 @@ public MapController(IConfig config) : base(config)
3232
/// <returns></returns>
3333
public HttpResponseMessage Get(string id)
3434
{
35+
var notfound = new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = $@"Map ""{id}"" does not exist!" };
3536
Bitmap bmp = null;
37+
var ms = new MemoryStream();
3638
try
3739
{
3840
bmp = MapResources.ResourceManager.GetObject($"topo_map_{id}") as Bitmap;
39-
}
40-
catch (MissingManifestResourceException) { }
41-
catch (MissingSatelliteAssemblyException) { }
41+
if (bmp == null) return notfound;
4242

43-
if (bmp == null) return new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = $@"Map ""{id}"" does not exist!" };
44-
45-
var ms = new MemoryStream();
46-
47-
try
48-
{
4943
var jpegEncoder = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Jpeg.Guid);
5044
var encParams = new EncoderParameters { Param = new[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L) } };
5145
if (jpegEncoder == null) return new HttpResponseMessage(HttpStatusCode.InternalServerError) { ReasonPhrase = "Could not find jpeg encoder." };
5246

5347
bmp.Save(ms, jpegEncoder, encParams);
5448
ms.Seek(0, SeekOrigin.Begin);
5549
}
50+
catch (MissingManifestResourceException) { return notfound; }
51+
catch (MissingSatelliteAssemblyException) { return notfound; }
5652
finally
5753
{
58-
bmp.Dispose();
54+
bmp?.Dispose();
5955
}
6056

6157
var result = new HttpResponseMessage(HttpStatusCode.OK)

ArkBot/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<package id="Accord.MachineLearning" version="3.5.0" targetFramework="net461" />
55
<package id="Accord.Math" version="3.5.0" targetFramework="net461" />
66
<package id="Accord.Statistics" version="3.5.0" targetFramework="net461" />
7+
<package id="ArkSavegameToolkitNet" version="1.1.0" targetFramework="net461" />
78
<package id="Autofac" version="4.3.0" targetFramework="net461" />
89
<package id="Autofac.Owin" version="4.0.0" targetFramework="net461" />
910
<package id="Autofac.SignalR" version="3.0.2" targetFramework="net461" />

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
# ARK Survival Evolved Discord Bot / Web App / Web API
1+
# ARK Survival Evolved Companion App / Discord Bot
22

33
![Web-app Interface](https://cloud.githubusercontent.com/assets/408350/26307865/044f849a-3ef7-11e7-930f-9ac829e58d45.png)
44

55
![Discord Bot Commands](https://cloud.githubusercontent.com/assets/408350/25876839/0a91380c-3520-11e7-9172-3a7707cd4c56.png)
66

7-
## NOTE
8-
9-
### This application is in the very early stages of development.
10-
11-
There are bugs, unfinished/missing features, unoptimized/crappy code, lack of testing and documentation.
12-
13-
147
## Introduction
158

16-
The application monitors and extracts data from any number of configured local ARK servers and exposes this data through a Discord Bot and Web API.
9+
An in-game companion app for players and Discord bot for server administrators.
10+
11+
The application monitors and extracts data from any number of configured local ARK servers and exposes this data through a Web App, Web API and Discord Bot.
1712

18-
It aims to provide important functions to players: dino listings, food-status, statistics; and server admins: rcon-commands, server managing etc. It does not enable cheating or making available data that have a considerable impact on how the game is played.
13+
It aims to provide important functions to players: dino listings, food-status, breeding info, statistics; and server admins: rcon-commands, server managing etc. It does not enable cheating or making available data that have a considerable impact on how the game is played.
1914

2015
Previously the application utilized a modified version of https://github.com/Qowyn/ark-tools to extract data from savegame-files. It has since been replaced by a faster and more configurable .NET-library developed in conjunction with this application based on Qowyns work on ark-tools.
2116

2217
The application also utilizes creature stat data sourced from Cadons excellent ARK Smart Breeding application (https://github.com/cadon/ARKStatsExtractor).
2318

2419
## Latest release
25-
Stable (currently not updated due to the extremely pre-release state of the application)
20+
### Stable
2621

2722
https://github.com/tsebring/ArkBot/releases
2823

29-
Pre-release built from latest sources (open as zip-archive, binaries under tools/)
24+
### Pre-release built from latest sources
25+
Open as zip-archive or change extension to .zip, binaries are located under tools/.
3026

3127
https://www.myget.org/F/tsebring/api/v2/package/ArkDiscordBot
3228

33-
## Configuration in config.json (copy defaultconfig.json template file)
29+
## Installation
30+
**For questions/problems: open a GitHub issue or contact me on Discord (Tobias#5051).**
3431

35-
### There are many fields that are not covered below and some information may not be up-to-date. Sticking to the defaultconfig.json setup with minimal changes according to your environment is the safest bet. Open a GitHub issue or contact me on Discord (Tobias#5051) if there are any problems.
32+
* Download the latest pre-built binaries (see above).
33+
* Copy defaultconfig.json and name it config.json.
34+
* Open config.json in a text editor and go through each setting and change according to your environment (settings are documented below).
35+
36+
## Documentation
3637

3738
**All config settings have descriptions that can be found in:**
3839
https://github.com/tsebring/ArkBot/blob/master/ArkBot/Config.cs.
@@ -102,31 +103,39 @@ The absolute path of a savegame-file (.ark) to watch for changes and extract dat
102103

103104
The absolute path of the directory where cluster-files are stored. Cluster-files are extracted as part of the server update process triggered by savegame-file (.ark) to watchers.
104105

106+
## Web App
107+
108+
n in-game companion app built on top of the Web API and implemented in Angular (https://angular.io/).
109+
110+
Features server status, server details, online player listing, per server player-/tribe listings, individual player profile with character- and creature information, including food-status, mating cooldowns, baby age and cuddle timers, breeding info, generator status, crop status, tribe logs and more.
111+
112+
Url: `webAppListenPrefix`
113+
Admin url: `webAppListenPrefix`/admin/`serverKey`
105114

106115
## Web API
107116

108117
RESTful API for accessing exported ARK Server save data via HTTP in JSON- or XML-format. A SignalR hub push server update notifications to connected clients in real-time.
109118

110-
The prebuilt web-app included in this release is by default configured to call the web api on 127.0.0.1:60001. If you want to use another port for the web api you will need to reflect this change in environment.prod.ts and rebuild the web-app dist manually.
119+
The prebuilt web-app included in this release is by default configured to call the web api on 127.0.0.1:60001. If you want to use another port for the web api you will need to reflect this change in environment.prod.ts and rebuild the web-app dist manually using `ng build --prod --bh /`.
111120

112121
### Endpoints (base path is configured in `webApiListenPrefix`)
113122

114-
/api/map/`mapName`: ARK topographic maps for (TheIsland, TheCenter and ScorchedEarth_P) sourced from ARK Survival Evolved Wiki (http://ark.gamepedia.com).
123+
/api/map/`mapName`: ARK topographic maps for (TheIsland, TheCenter, ScorchedEarth_P and Ragnarok) sourced from ARK Survival Evolved Wiki (http://ark.gamepedia.com).
115124

116125
/api/player/`steamId`: Player data for player identified by `steamId` from each configured server instance.
117126

118127
/api/server/`serverKey`: Player and tribe listing from each configured server instance.
119128

120-
/api/adminserver/`serverKey`: Player and tribe listingwith additional creature and structure counts from each configured server instance.
129+
/api/adminserver/`serverKey`: Player and tribe listing with additional creature and structure counts from each configured server instance.
121130

122-
/api/servers: Server status information including active players and statistics for each configured server instance.
131+
/api/structures/`serverKey`: Clustered structure data used to show the location of tribes/structures in the ARK.
123132

124-
/signalr/ (hub name `ServerUpdateHub`): Server update notifications using SignalR.
133+
With [ARK-Server-Beyond-API](https://github.com/tsebring/ARK-Server-Beyond-API) and [ImprovedCommands](https://github.com/tsebring/ImprovedCommands) administrators may remotely destroy and clean-up old structures and tamed creatures in the ARK.
125134

126-
## Web-app (under development)
135+
/api/servers: User-, access control- and server status information including active players and statistics for each configured server instance.
127136

128-
A web application built on top of the Web API and implemented in Angular (https://angular.io/).
137+
/api/administer/`...`: Rcon and other commands exposed through the web app.
129138

130-
Features server status, online player listing, per server player-/tribe listings, individual player profile with character- and creature information with food-status, mating cooldowns, baby age and cuddle timers.
139+
/api/authentication/`...`: Authenticate players using Steam.
131140

132-
Url: `webAppListenPrefix`/servers
141+
/signalr/ (hub name `ServerUpdateHub`): Server update notifications using SignalR.

0 commit comments

Comments
 (0)