多项新特性和更改:
- 添加模拟数据生成器; - GC时添加碎片整理; - 优化日志输出,添加更多DEBUG监控项目; - 修复输出时分库配置逻辑的严重错误; - 优化了少许内存性能,减少Lambda闭包分配;
This commit is contained in:
@@ -39,6 +39,10 @@ public class DataRecordQueue : IDisposable
|
||||
{
|
||||
if (_queue.TryTake(out record))
|
||||
{
|
||||
// if (record.Database is not null)
|
||||
// {
|
||||
// Console.WriteLine("out " + record.Database);
|
||||
// }
|
||||
Interlocked.Add(ref _currentCharCount, -record.FieldCharCount);
|
||||
OnRecordRead?.Invoke();
|
||||
return true;
|
||||
|
@@ -9,6 +9,7 @@ public sealed class OutputErrorRecorder : ErrorRecorder
|
||||
private readonly string _outputDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"ErrorRecords/{UID}/Output");
|
||||
private readonly string _database;
|
||||
private readonly Dictionary<string, int> _logIndex = new();
|
||||
private static readonly object Lock = new();
|
||||
|
||||
public OutputErrorRecorder(string database, ILogger logger) : base(logger)
|
||||
{
|
||||
@@ -50,7 +51,17 @@ public sealed class OutputErrorRecorder : ErrorRecorder
|
||||
|
||||
|
||||
""";
|
||||
await File.AppendAllTextAsync(filePath, content, Encoding.UTF8);
|
||||
try
|
||||
{
|
||||
lock (Lock)
|
||||
{
|
||||
File.AppendAllText(filePath, content, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.LogError(e, "输出错误日志时发生错误");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -59,11 +59,12 @@ public class ProcessContext
|
||||
|
||||
public void AddTableInput(string table, int count)
|
||||
{
|
||||
_tableProgress.AddOrUpdate(table, (input:count, output:0), (k, tuple) =>
|
||||
if (!_tableProgress.TryAdd(table, (input: count, output: 0)))
|
||||
{
|
||||
var tuple = _tableProgress[table];
|
||||
tuple.input += count;
|
||||
return tuple;
|
||||
});
|
||||
_tableProgress[table] = tuple;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTableOutput(string table, int count)
|
||||
|
@@ -117,6 +117,7 @@ public class SeqService
|
||||
/// </summary>
|
||||
public async Task ApplyToDatabaseAsync()
|
||||
{
|
||||
if (_cachedSequence.Count == 0) return;
|
||||
var sql = GenerateCachedSeqSql();
|
||||
await DatabaseHelper.NonQueryAsync(_connectionString, sql);
|
||||
}
|
||||
|
Reference in New Issue
Block a user