8000 Fix several crashes in the object store benchmarks by tgoyne · Pull Request #7403 · realm/realm-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix several crashes in the object store benchmarks #7403

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

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-----------

### Internals
* None.
* Fix several crashes when running the object store benchmarks ([#7403](https://github.com/realm/realm-core/pull/7403)).

----------------------------------------------

Expand Down
30 changes: 9 additions & 21 deletions test/object-store/benchmarks/object.cpp
8000
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {
using AnyDict = std::map<std::string, std::any>;
_impl::RealmCoordinator::assert_no_open_realms();

InMemoryTestFile config;
TestFile config;
config.in_memory = true;
Comment on lines +157 to +158
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "new" in-memory lockfile supports a maximum of 32 live versions and this test needs >200.

config.automatic_change_notifications = false;
config.schema = Schema{
{"all types",
Expand Down Expand Up @@ -304,7 +305,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(500, 5000);
int64_t benchmark_pk = dist(rng);
for (size_t i = 0; i < 1000; ++i) {
for (int64_t i = 0; i < 1000; ++i) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int64_t + size_t = size_t, so size_t here resulted in benchmark_pk + i being size_t and thus the any_cast<int64_t>() when reading the value threw.

auto obj = Object::create(d, r, all_types,
std::any(AnyDict{
{"pk", benchmark_pk + i},
Expand Down Expand Up @@ -343,19 +344,6 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {
});
r->commit_transaction();
};

// TODO remove this once Object::obj() is deleted.
// BENCHMARK_ADVANCED("update object obj()")(Catch::Benchmark::Chronometer meter)
// {
// r->begin_transaction();
// meter.measure([&objs, &col_int] {
// for (Object& obj : objs) {
// obj.obj().set(col_int, 10);
// REQUIRE(obj.obj().get<Int>(col_int) == 10);
// }
// });
// r->commit_transaction();
// };
}

SECTION("change notifications reporting") {
Expand Down Expand Up @@ -388,7 +376,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {

r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
auto name = util::format("person_", i);
auto name = util::format("person_%1", i);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was obviously just incorrect.

AnyDict person{
{"name", name},
{"age", static_cast<int64_t>(i)},
Expand Down Expand Up @@ -424,7 +412,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {

r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
auto name = util::format("person_", i);
auto name = util::format("person_%1", i);
AnyDict person{
{"name", name},
{"age", static_cast<int64_t>(i)},
Expand Down Expand Up @@ -464,7 +452,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {

r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
auto name = util::format("person_", i);
auto name = util::format("person_%1", i);
AnyDict person{
{"name", name},
{"age", static_cast<int64_t>(i)},
Expand All @@ -483,7 +471,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {

r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
auto name = util::format("person_", i);
auto name = util::format("person_%1", i);
AnyDict person{
{"name", name}, {"age", static_cast<int64_t>(i + 1)}, // age differs
};
Expand Down Expand Up @@ -620,7 +608,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {
r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
size_t index = i + start_index;
auto name = util::format("person_", index);
auto name = util::format("person_%1", index);
AnyDict person{
{"name", name},
{"age", static_cast<int64_t>(index)},
Expand Down Expand Up @@ -738,7 +726,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {

r->begin_transaction();
for (size_t i = 0; i < num_objects; ++i) {
auto name = util::format("person_", i);
auto name = util::format("person_%1", i);
AnyDict person{
{"name", name},
{"age", static_cast<int64_t>(i * 2)},
Expand Down
0