-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GC. * Impl gc. * Fix linking. * Using thread pool. * Using try_dequeue. * Stop workers when destruct. * Set default worker size to 8. * Add repeat task for all. * Update flags. * Add comments. * Fix nightly.
- Loading branch information
Showing
20 changed files
with
119 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
nebula_add_library( | ||
gc_obj OBJECT | ||
GC.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2022 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#include "graph/gc/GC.h" | ||
|
||
#include "graph/service/GraphFlags.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
GC& GC::instance() { | ||
static GC gc; | ||
return gc; | ||
} | ||
|
||
GC::GC() { | ||
if (FLAGS_gc_worker_size == 0) { | ||
workers_.start(std::thread::hardware_concurrency(), "GC"); | ||
} else { | ||
workers_.start(FLAGS_gc_worker_size, "GC"); | ||
} | ||
workers_.addRepeatTaskForAll(50, &GC::periodicTask, this); | ||
} | ||
|
||
void GC::clear(std::vector<Result>&& garbage) { | ||
queue_.enqueue(std::move(garbage)); | ||
} | ||
|
||
void GC::periodicTask() { | ||
// TODO: maybe could release by batch | ||
queue_.try_dequeue(); | ||
} | ||
} // namespace graph | ||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2022 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#ifndef GRAPH_GC_H_ | ||
#define GRAPH_GC_H_ | ||
|
||
#include "common/base/Base.h" | ||
#include "common/thread/GenericThreadPool.h" | ||
#include "graph/context/Result.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
// Clean the unused memory on background threads, this is helpful | ||
// for big queries since the memory release of interim results may | ||
// cost too much time. | ||
class GC { | ||
public: | ||
static GC& instance(); | ||
|
||
~GC() { | ||
workers_.stop(); | ||
} | ||
|
||
void clear(std::vector<Result>&& garbage); | ||
|
||
private: | ||
GC(); | ||
void periodicTask(); | ||
folly::UMPMCQueue<std::vector<Result>, false> queue_; | ||
thread::GenericThreadPool workers_; | ||
}; | ||
} // namespace graph | ||
} // namespace nebula | ||
#endif // GRAPH_GC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters