mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Use tessil/unordered-map instead of nlohmann/fifo-map to mitigate performance issues when logging JSON
This commit is contained in:
parent
1253a61340
commit
c8f2d52d91
4 changed files with 24 additions and 10 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit c1eab215ae34b2bc03fcb8c787b386a25e00bf3e
|
Subproject commit 10307377157d71c0ad0d3fd33ccf7e04ce8f65ff
|
|
@ -441,12 +441,17 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/fifo_map.hpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/json.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/json.hpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/sqlite3.h
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/sqlite3.h
|
||||||
DESTINATION include/zeek/3rdparty
|
DESTINATION include/zeek/3rdparty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tsl-ordered-map/ordered_map.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tsl-ordered-map/ordered_hash.h
|
||||||
|
DESTINATION include/zeek/3rdparty/tsl-ordered-map
|
||||||
|
)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
## Clang-tidy target now that we have all of the sources
|
## Clang-tidy target now that we have all of the sources
|
||||||
|
|
||||||
|
|
13
src/Val.cc
13
src/Val.cc
|
@ -28,14 +28,19 @@
|
||||||
#include "broker/Data.h"
|
#include "broker/Data.h"
|
||||||
|
|
||||||
#include "3rdparty/json.hpp"
|
#include "3rdparty/json.hpp"
|
||||||
#include "3rdparty/fifo_map.hpp"
|
#include "3rdparty/tsl-ordered-map/ordered_map.h"
|
||||||
|
|
||||||
|
|
||||||
// Define a class for use with the json library that orders the keys in the same order that
|
// Define a class for use with the json library that orders the keys in the same order that
|
||||||
// they were inserted. By default, the json library orders them alphabetically and we don't
|
// they were inserted. By default, the json library orders them alphabetically and we don't
|
||||||
// want it like that.
|
// want it like that.
|
||||||
template<class K, class V, class compare, class A>
|
template<class Key, class T, class Ignore, class Allocator,
|
||||||
using json_fifo_map = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
|
class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
|
||||||
using ZeekJson = nlohmann::basic_json<json_fifo_map>;
|
class AllocatorPair = typename std::allocator_traits<Allocator>::template rebind_alloc<std::pair<Key, T>>,
|
||||||
|
class ValueTypeContainer = std::vector<std::pair<Key, T>, AllocatorPair>>
|
||||||
|
using ordered_map = tsl::ordered_map<Key, T, Hash, KeyEqual, AllocatorPair, ValueTypeContainer>;
|
||||||
|
|
||||||
|
using ZeekJson = nlohmann::basic_json<ordered_map>;
|
||||||
|
|
||||||
Val::Val(Func* f)
|
Val::Val(Func* f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "../Formatter.h"
|
#include "../Formatter.h"
|
||||||
#include "3rdparty/json.hpp"
|
#include "3rdparty/json.hpp"
|
||||||
#include "3rdparty/fifo_map.hpp"
|
#include "3rdparty/tsl-ordered-map/ordered_map.h"
|
||||||
|
|
||||||
|
|
||||||
namespace threading { namespace formatter {
|
namespace threading { namespace formatter {
|
||||||
|
@ -12,9 +12,13 @@ namespace threading { namespace formatter {
|
||||||
// Define a class for use with the json library that orders the keys in the same order that
|
// Define a class for use with the json library that orders the keys in the same order that
|
||||||
// they were inserted. By default, the json library orders them alphabetically and we don't
|
// they were inserted. By default, the json library orders them alphabetically and we don't
|
||||||
// want it like that.
|
// want it like that.
|
||||||
template<class K, class V, class compare, class A>
|
template<class Key, class T, class Ignore, class Allocator,
|
||||||
using json_fifo_map = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
|
class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
|
||||||
using ZeekJson = nlohmann::basic_json<json_fifo_map>;
|
class AllocatorPair = typename std::allocator_traits<Allocator>::template rebind_alloc<std::pair<Key, T>>,
|
||||||
|
class ValueTypeContainer = std::vector<std::pair<Key, T>, AllocatorPair>>
|
||||||
|
using ordered_map = tsl::ordered_map<Key, T, Hash, KeyEqual, AllocatorPair, ValueTypeContainer>;
|
||||||
|
|
||||||
|
using ZeekJson = nlohmann::basic_json<ordered_map>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread-safe class for converting values into a JSON representation
|
* A thread-safe class for converting values into a JSON representation
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue